Problems selecting records
-
Hi, I'm having a problem selecting records from my database to display on the web page. I want to select all records with a specific name, and on a specific date. The code I'm using looks like this:
StrConnect = Server.MapPath("./MyDataBase.mdb") cn = Server.CreateObject("ADODB.Connection") cn.Open("PROVIDER=MICROSOFT.JET.OLEDB.4.0;Data Source =" & StrConnect) rs = Server.CreateObject("ADODB.Recordset") rs.Open("SELECT * FROM TheLog WHERE name='123' AND recdate=#01/02/2003#", cn, 3)
Now despite there being about 5 records with that name and date, I don't get any records returned. Does anyone know why? P.S. The database is a Access database, the name field is set to "Text" and the recdate field is set to "Date/Time" - Munty -
Hi, I'm having a problem selecting records from my database to display on the web page. I want to select all records with a specific name, and on a specific date. The code I'm using looks like this:
StrConnect = Server.MapPath("./MyDataBase.mdb") cn = Server.CreateObject("ADODB.Connection") cn.Open("PROVIDER=MICROSOFT.JET.OLEDB.4.0;Data Source =" & StrConnect) rs = Server.CreateObject("ADODB.Recordset") rs.Open("SELECT * FROM TheLog WHERE name='123' AND recdate=#01/02/2003#", cn, 3)
Now despite there being about 5 records with that name and date, I don't get any records returned. Does anyone know why? P.S. The database is a Access database, the name field is set to "Text" and the recdate field is set to "Date/Time" - MuntyTry using a range of dates (eg. between 01/02/2003 00:00:00 and 01/02/2003 23:59:59, don't use my syntax ) rather than specifying recdate to be exactly equal to 01/02/2003
_______________________________________________________________________ http://www.readytogiveup.com/[^] "you can't forget something you never knew..." M. Du Toit
-
Try using a range of dates (eg. between 01/02/2003 00:00:00 and 01/02/2003 23:59:59, don't use my syntax ) rather than specifying recdate to be exactly equal to 01/02/2003
_______________________________________________________________________ http://www.readytogiveup.com/[^] "you can't forget something you never knew..." M. Du Toit
-
Hi, I'm having a problem selecting records from my database to display on the web page. I want to select all records with a specific name, and on a specific date. The code I'm using looks like this:
StrConnect = Server.MapPath("./MyDataBase.mdb") cn = Server.CreateObject("ADODB.Connection") cn.Open("PROVIDER=MICROSOFT.JET.OLEDB.4.0;Data Source =" & StrConnect) rs = Server.CreateObject("ADODB.Recordset") rs.Open("SELECT * FROM TheLog WHERE name='123' AND recdate=#01/02/2003#", cn, 3)
Now despite there being about 5 records with that name and date, I don't get any records returned. Does anyone know why? P.S. The database is a Access database, the name field is set to "Text" and the recdate field is set to "Date/Time" - Munty -
name is reserved word in TSQL
Muntyness wrote:
WHERE name='123'
and you try this
"SELECT * FROM TheLog WHERE [name]='123' AND recdate=#01/02/2003#"
I Love SQL
Name is reserved? Bah. Well I've changed the field to Job now. and I've tried both: "SELECT * FROM TheLog WHERE job='123' AND recdate=#01/02/2003#" And "SELECT * FROM TheLog WHERE [job]='123' AND recdate=#01/02/2003#" Neither of them work. This does work however: "SELECT * FROM TheLog WHERE job='123'" - Munty