If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Syntax error (missing operator) in query expression

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-05-03, 05:47
rohitrs rohitrs is offline
Registered User
 
Join Date: Dec 2003
Posts: 1
Syntax error (missing operator) in query expression

I have this query in ASP to get data from Access Database.

sql1="SELECT G1M40.G1A_Date, G1M40.G1A_Shift, G1M40.G1A_M+40mm1, G1M40.G1A_M+10mm1 " &_
" FROM G1M40 WHERE G1M40.G1A_Date = #" & currdate & "#ORDER BY G1M40.G1A_Date"

When I run the ASP page I get error:
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'G1M40.G1A_M+40mm1'.

I cannot change the column name of table. Please let me know if there is any other option.
Reply With Quote
  #2 (permalink)  
Old 12-05-03, 06:13
jlot6 jlot6 is offline
Registered User
 
Join Date: Sep 2003
Location: Newark, Vermont
Posts: 20
Re: Syntax error (missing operator) in query expression

Code:
  sql1="SELECT G1M40.G1A_Date, G1M40.G1A_Shift, G1M40.G1A_M+40mm1, G1M40.G1A_M+10mm1 " &_
" FROM G1M40 WHERE G1M40.G1A_Date = #" & currdate & "#ORDER BY G1M40.G1A_Date"
# ORDER BY G1M40.G1A_Date
Try spacing # and ORDER

Quote:
Originally posted by rohitrs
I have this query in ASP to get data from Access Database.

sql1="SELECT G1M40.G1A_Date, G1M40.G1A_Shift, G1M40.G1A_M+40mm1, G1M40.G1A_M+10mm1 " &_
" FROM G1M40 WHERE G1M40.G1A_Date = #" & currdate & "#ORDER BY G1M40.G1A_Date"

When I run the ASP page I get error:
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'G1M40.G1A_M+40mm1'.

I cannot change the column name of table. Please let me know if there is any other option.
Reply With Quote
  #3 (permalink)  
Old 12-05-03, 09:03
sivaroo sivaroo is offline
Registered User
 
Join Date: Nov 2003
Posts: 76
try using square bracket for field names when you have +,- or spaces.
[G1M40].[G1A_M+40mm1], [G1M40].[G1A_M+10mm1]
Reply With Quote
  #4 (permalink)  
Old 12-07-03, 05:11
rnealejr rnealejr is offline
Registered User
 
Join Date: Feb 2002
Posts: 2,232
Sivaroo is correct. When you are using key/reserved characters/words you need to put brackets around the objects name.
Reply With Quote
  #5 (permalink)  
Old 04-07-04, 09:46
aiyong04 aiyong04 is offline
Registered User
 
Join Date: Apr 2004
Posts: 1
Quote:
Originally posted by rnealejr
Sivaroo is correct. When you are using key/reserved characters/words you need to put brackets around the objects name.
I'm having almost the same problem, can anybody figure out for me.
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E10)
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
SQL = "SELECT count(*) as DateMatch FROM tblNotice WHERE DateNotie > '"&tempLastDate&"'" //tempLastDate has value 04/04/2004

If I use this, SQL = "SELECT count(*) as DateMatch FROM tblNotice WHERE DateNotice > #04/04/2004# " //the result can be displayed out.

If I use this, SQL = "SELECT count(*) as DateMatch FROM tblNotice WHERE DateNotie > '#"&tempLastDate&"'#"
Syntax error in date in query expression 'DateNotie > '#4/4/2004'#'.

i'm writing in asp code.
Reply With Quote
  #6 (permalink)  
Old 04-07-04, 10:13
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
"SELECT ... WHERE DateNotie > #"&tempLastDate&"#"

no quotes for access date strings, just the hash marks
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On