Error message with sql statement

J

Jack

Hi,
I got a asp page where I am getting the following error. (Line 126 is
actually the
RS.open statement.)

ERROR MESSAGE

Technical Information (for support personnel)

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in
query expression 'GrantID ='.
/gwis/Recalc.asp, line 126

THE FOLLOWING IS THE PART OF CODE THAT IS PRODUCING ERROR:
'New Connection
myDSN="DRIVER={Microsoft Access Driver (*.mdb)}; "
myDSN=myDSN & "DBQ=C:\gwis Data\fpdb\GWIS.mdb"
set CN=server.createobject("ADODB.Connection")
set RS=server.createobject("ADODB.Recordset")
CN.Open "myDSN"

RS.ActiveConnection=CN

SQL = "SELECT COUNT(*) AS reccount FROM CurrentQuarterTbl WHERE GrantID =
" & GrantID & ";"
RS.Open SQL

Any help is appreciated in advance. Thanks.
 
B

Bob Barrows [MVP]

Jack said:
Hi,
I got a asp page where I am getting the following error. (Line 126 is
actually the
RS.open statement.)

ERROR MESSAGE

Technical Information (for support personnel)

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing
operator) in query expression 'GrantID ='.
/gwis/Recalc.asp, line 126

THE FOLLOWING IS THE PART OF CODE THAT IS PRODUCING ERROR:
'New Connection
myDSN="DRIVER={Microsoft Access Driver (*.mdb)}; "
http://www.aspfaq.com/show.asp?id=2126


myDSN=myDSN & "DBQ=C:\gwis Data\fpdb\GWIS.mdb"
set CN=server.createobject("ADODB.Connection")
set RS=server.createobject("ADODB.Recordset")
CN.Open "myDSN"

RS.ActiveConnection=CN

SQL = "SELECT COUNT(*) AS reccount FROM CurrentQuarterTbl WHERE
GrantID = " & GrantID & ";"

You cannot debug a sql statement without knowing what it is. Knowing what
the vbscript code that is supposed to result in a valid sql statement looks
like is less than half the battle. Add this line:

Response.Write SQL

Look at the statement that appears in the browser window. Does the error
stand out? If not, open your database in Access, and use the query builder
to test the statement from the browser window. Still can't see the error?
Post the sql statement here.

Take a look at these posts:


http://www.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&[email protected]

http://www.google.com/groups?hl=en&...ows&hl=en&lr=&ie=UTF-8&oe=UTF-8&start=10&sa=N

Bob Barrows
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top