Error message with sql statement

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jack

    Error message with sql statement

    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:\gwi s Data\fpdb\GWIS. mdb"
    set CN=server.creat eobject("ADODB. Connection")
    set RS=server.creat eobject("ADODB. Recordset")
    CN.Open "myDSN"

    RS.ActiveConnec tion=CN

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

    Any help is appreciated in advance. Thanks.
  • Bob Barrows [MVP]

    #2
    Re: Error message with sql statement

    Jack wrote:[color=blue]
    > 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)}; "[/color]



    [color=blue]
    > myDSN=myDSN & "DBQ=C:\gwi s Data\fpdb\GWIS. mdb"
    > set CN=server.creat eobject("ADODB. Connection")
    > set RS=server.creat eobject("ADODB. Recordset")
    > CN.Open "myDSN"
    >
    > RS.ActiveConnec tion=CN
    >
    > SQL = "SELECT COUNT(*) AS reccount FROM CurrentQuarterT bl WHERE
    > GrantID = " & GrantID & ";"[/color]

    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:






    Bob Barrows

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.


    Comment

    Working...