Accessing data in Access through IE using ASP [Archive] - SpeedGuide.net Broadband Community

View Full Version : Accessing data in Access through IE using ASP


TinyTim
02-25-05, 02:37 PM
I had a question about accessing an Access database using SQL statements through IE...probably pretty simple...here is what I have so far:

<%


Set demoConn = Server.CreateObject("ADODB.Connection")
'this is the line to change
demoFilePath = "c:\inetpub\wwwroot\SI\tracking.mdb"
demoConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & demoFilePath & ";"

myQuery = "SELECT * FROM SILog WHERE DATE <= “””2005-12-31”” and date >= ””2005-01-01”””"

Set recordCollection = demoConn.Execute(myQuery)

-----My question is here, I want to select all record within a certain date range, I know the SQL statement would be: SELECT * FROM SILog WHERE date <= '2005-12-31' and date >= '2005-01-01' ----the problem is the single quotes, becuase in ASP you would need to use the double quotes to define the statement...anyway, when I run it, it returns 0 records...there should be 19. It works when I run through the SQL query analyzer, just not IE...any ideas?


Response.Write("<TABLE
BORDER=1><TR><TH>ID</TH><TH>Date</TH><TH>Complaint</TH><TH>Referred
To</TH><TH>Date Referred</TH><TH>Initials</TH></TR>")

Do While NOT recordCollection.EOF
Response.Write("<TR>")
For x=0 to recordCollection.Fields.Count-1
Response.Write("<TD>")
Response.Write(recordCollection(x))
Response.Write("</TD>")
Next

Response.Write("</TR>")
recordCollection.MoveNext

Loop

Response.Write("</TABLE>")

demoConn.Close
Set demoConn=Nothing

%>

Any ideas?

TinyTim
02-28-05, 09:07 AM
Ok, I figured out that the date format in SQL commands is formatted differently then in the MS Access database, that is why it returns 0 results...I moved the Access database to the SQL server--and thus arises a new problem, which I will post in a new thread.....