Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old May 6th, 2003, 01:18 AM
pixel_ronin pixel_ronin is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 8 pixel_ronin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question SQL syntax for filtering a table by a column

I would like to filter my 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("ADODB.Recordset")
SQLDATE = "SELECT * FROM Events WHERE Category = dance AND (Month(Date) = Month('"&dateSelect&"')) AND (Year(Date) = Year('"&dateSelect&"')) AND (Day(Date) = Day('"&dateSelect&"'))"
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

Reply With Quote
  #2  
Old May 6th, 2003, 05:49 PM
aspnewbie aspnewbie is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: The Great White North
Posts: 361 aspnewbie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 50 sec
Reputation Power: 7
Send a message via MSN to aspnewbie
This page has a few suggestions:

http://www.aspfaq.com/show.asp?id=2128.

Also, with access you need to surround the date variable with the # key

http://www.aspfaq.com/show.asp?id=2040

Is your field name called date?


Last edited by aspnewbie : May 6th, 2003 at 05:55 PM.

Reply With Quote
  #3  
Old May 7th, 2003, 01:36 AM
pixel_ronin pixel_ronin is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 8 pixel_ronin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
got it!

I solved it.

<%Set RSDATE = Server.CreateObject("ADODB.Recordset")SQLDATE = "SELECT * FROM Events WHERE Category = 'theater' AND (Month(Date) = " & Month(dateSelect) & ") AND (Year(Date) = " & Year(dateSelect) & ") AND (Day(Date) = " & Day(dateSelect) & ")"
RSDATE.Open SQLDATE, Conn, 1, 3
do while NOT RSDATE.EOF%>

thanks

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft SQL Server > SQL syntax for filtering a table by a column


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT