Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL syntax for filtering a table by a column

Status
Not open for further replies.

pixelRONIN

Technical User
Apr 11, 2003
9
US
I would like to filter an Access DB which has a table named "events" by a column named "category". Within the column, I have five "event" catagories in which I would like to filter the Event table by.
Here I have opened the DB:

dsn="DBQ=" & Server.Mappath("admin/o12cal.mdb") & ";Driver={Microsoft Access Driver (*.mdb)};"
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open dsn

Here is my attempt to filter the Events:

<%Set RSDATE = Server.CreateObject(&quot;ADODB.Recordset&quot;)
SQLDATE = &quot;SELECT * FROM Events WHERE Category = dance AND (Month(Date) = Month('&quot;&dateSelect&&quot;')) AND (Year(Date) = Year('&quot;&dateSelect&&quot;')) AND (Day(Date) = Day('&quot;&dateSelect&&quot;'))&quot;
RSDATE.Open SQLDATE, Conn, 1, 3

That statement brings up an ASP error:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E10)
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.

Any suggestions?

Thanks
pr

 
Try:

SQLDATE = &quot;SELECT * FROM Events WHERE Category = dance AND (Month(Date) = &quot; & Month(dateSelect) & &quot;) AND (Year(Date) = &quot; & Year(dateSelect) & &quot;) AND (Day(Date) = &quot; & Day(dateSelect) & &quot;)&quot;
RSDATE.Open SQLDATE, Conn, 1, 3

HTH



[pipe]
Daniel Vlas
Systems Consultant

 
Well, at least this *is* progress!
I changed the syntax - but I recieved this error.

Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: '[string: &quot;SELECT * FROM Events&quot;]'

Thanks for the prompt reply,
pr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top