Query through ASP.NET...Date problems?

Phoenix00017

New member
Local time
Today, 13:18
Joined
Jul 8, 2003
Messages
6
I'm trying to run a query with ASP.NET of my Access DB. So far all of my queries have worked fine - at least, until I tried using a date as one of my WHERE conditions. When I remove the date requirement in the code below, the query works fine. However, when I add the date back, it yields no results. I've tried making the variable "tempdate" a DateTime variable, a String, and a DateTime variable converted to a String. I give up...what am I doing wrong? (tempclassval is just an integer)

strSQLQuery = "SELECT TEquipmentList.Equipment as name, TEquipmentList.EquipmentID as id FROM TEquipmentList LEFT JOIN TSignOutTable ON TEquipmentList.EquipmentID = TSignOutTable.EquipmentID WHERE TSignOutTable.Date=" & CStr(tempdate) & " AND TSignOutTable.ClassID= " & tempclassval & ";"

Thanks for the help!
 
Got it figured out...

Ok, well, for the record, I got the answer. Around non-numeric variables, there must be single quotes. This can lead to some really crazy quote battles (sometimes requiring something like:
"... WHERE table.date = '"&tempdate&"'"

Here's a helpful tutorial to which I owe the answer:
http://www.aspexpress.com/tutorials/tutorial.asp?id=2
 

Users who are viewing this thread

Back
Top Bottom