Last post Apr 28, 2008 08:56 AM by Mikesdotnetting
Apr 28, 2008 08:25 AM|sunhuman|LINK
I use Access as the database. (Running .net 1.1)
I have used a code to retieve records that fall between a particular date. There is no error when I run the page.
But the result shows all the records and the condition that I have specified does not have any effect.
Below is the Query I have used in my ASP.net page
Dim cmdAR1 As New OleDbCommand("select Username,EquipmentCode,EquipmentName,Department,Division,LastCertDate,CertDueDate,FreqCalibration,Remarks from register where CertDueDate> " & CDD_Date & " and CertDueDate < " & FCDD_Date & " order by CertDueDate asc",
The Dates are stored in Variabled (CDD_Date and FCDD_Date)
As this did work I even tried to hard code a date
I have been searching the net all day, but no luck.... What am I doing wrong here?
Apr 28, 2008 08:56 AM|Mikesdotnetting|LINK
If you insist on using dynamic SQL (variables concatenated into a string) you need to make sure the datatype delimiters are correct. In this case, since the datatype is datetime, you should delimit your values using single quotes or octothorpes (#). However,
you can get round this problem, and produce much safer code by using parameters: