Code Bank
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingCode Bank

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old December 15th, 2004, 02:04 PM
JAM1515 JAM1515 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 16 JAM1515 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 36 m 16 sec
Reputation Power: 0
Syntax Error - Query from Newbie

I hope this is something simple. I am new so just hacking away here but I'm stuck.

I just want to filter my results first by the OfficeID and then if they are authorised. Here is the code:

Code:
'Initalise the strSQL variable with an SQL statement to query the database by selecting all tables ordered by the decending date
strSQL = "SELECT " & strDbTable & "Comments.* " & _
"FROM " & strDbTable & "Comments "
strSQL = strSQL & "WHERE "& strDBTable & "Comments.OfficeID = 1 "
If strDatabaseType = "SQLServer" Then
 strSQL = strSQL & "WHERE " & strDbTable & "Comments.Authorised = 1 "
Else
 strSQL = strSQL & "WHERE " & strDbTable & "Comments.Authorised = true " 
End If
strSQL = strSQL & "ORDER BY Date_stamp DESC;"
'Set the cursor type property of the record set to dynamic so we can naviagate through the record set
rsCommon.CursorType = 3
 
'Query the database
rsCommon.Open strSQL, adoCon  


Here is my error message:
Code:
 Error Type:
Microsoft JET Database Engine (0x80040E14)
Syntax error (missing operator) in query expression 'tblGBComments.OfficeID = 1 WHERE tblGBComments.Authorised = true'.
 


Any help is appreciated! Thanks.

Reply With Quote
  #2  
Old December 15th, 2004, 02:49 PM
A2k's Avatar
A2k A2k is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 166 A2k User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 18 h 44 m 10 sec
Reputation Power: 4
Where you have "WHERE" I think you want AND

SQL statements have the following syntax:

SELECT [field list]
FROM [tables]
WHERE [contition] and/or [contition1] and/or [conditionX]

Reply With Quote
  #3  
Old December 15th, 2004, 04:13 PM
JAM1515 JAM1515 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 16 JAM1515 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 36 m 16 sec
Reputation Power: 0
You have made my day. (week actually) Thank you for replying to my message.

Jamee

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingCode Bank > Syntax Error - Query from Newbie


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 2 hosted by Hostway
Stay green...Green IT