Annoying syntax error

Discussion in 'ASP General' started by ree, Oct 20, 2003.

  1. ree

    ree Guest

    For some reason I can't pin point, it is just bugging me like hell.

    <%
    dim strQuery
    strQuery = "UPDATE Gifts SET"
    strQuery = strQuery & " GuestSelected = " & cint(guestID)
    strQuery = strQuery & ", DateSelected = " & Now()
    strQuery = strQuery & " WHERE GiftID = " & selectGiftID' &
    ";"

    Line 47 -> conn.Execute(strQuery)
    %>



    Error message

    Error Type:
    Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
    [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing
    operator) in query expression '21/10/2003 12:19:31 AM'.
    /selectGift.asp, line 47


    Browser Type:
    Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)

    Page:
    POST 8 bytes to /selectGift.asp

    POST Data:
    GiftID=5

    Time:
    Tuesday, 21 October 2003, 12:19:31 AM


    Thanks
    ree, Oct 20, 2003
    #1
    1. Advertising

  2. > strQuery = strQuery & ", DateSelected = " & Now()

    Access requies # to delimit dates, but Access also knows what now() is, so
    instead of trying to concatenate from ASP, just say

    strQuery = strQuery & ", DateSelected = Now()"

    > Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
    > [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing
    > operator) in query expression '21/10/2003 12:19:31 AM'.


    And stop using ODBC.
    http://www.aspfaq.com/2126
    Aaron Bertrand - MVP, Oct 20, 2003
    #2
    1. Advertising

  3. ree

    Tom B Guest

    In access, your dates need to be surrounded by #'s.

    "ree" <> wrote in message
    news:Xns941B3A5A27B4reehotmailcoom@210.49.20.254...
    > For some reason I can't pin point, it is just bugging me like hell.
    >
    > <%
    > dim strQuery
    > strQuery = "UPDATE Gifts SET"
    > strQuery = strQuery & " GuestSelected = " & cint(guestID)
    > strQuery = strQuery & ", DateSelected = " & Now()
    > strQuery = strQuery & " WHERE GiftID = " & selectGiftID' &
    > ";"
    >
    > Line 47 -> conn.Execute(strQuery)
    > %>
    >
    >
    >
    > Error message
    >
    > Error Type:
    > Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
    > [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing
    > operator) in query expression '21/10/2003 12:19:31 AM'.
    > /selectGift.asp, line 47
    >
    >
    > Browser Type:
    > Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
    >
    > Page:
    > POST 8 bytes to /selectGift.asp
    >
    > POST Data:
    > GiftID=5
    >
    > Time:
    > Tuesday, 21 October 2003, 12:19:31 AM
    >
    >
    > Thanks
    Tom B, Oct 20, 2003
    #3
  4. ree

    Randy Rahbar Guest

    > strQuery = strQuery & " WHERE GiftID = " & selectGiftID' &

    What's with the single quote after selectGiftID?

    > ";"


    You might want to lose that too. Assuming selectGiftID is numeric, change
    the last line to...
    strQuery = strQuery & " WHERE GiftID = " & selectGiftID
    Randy Rahbar, Oct 20, 2003
    #4
  5. ree

    Ray at Guest

    "ree" <> wrote in message
    news:Xns941B3A5A27B4reehotmailcoom@210.49.20.254...
    > For some reason I can't pin point, it is just bugging me like hell.
    >
    > <%
    > dim strQuery
    > strQuery = "UPDATE Gifts SET"
    > strQuery = strQuery & " GuestSelected = " & cint(guestID)
    > strQuery = strQuery & ", DateSelected = " & Now()
    > strQuery = strQuery & " WHERE GiftID = " & selectGiftID' & ";"
    >
    > Line 47 -> conn.Execute(strQuery)
    > %>
    >
    >


    Dates are delimited with # in Access databases.


    <%
    strQuery = "UPDATE Gifts SET"
    strQuery = strQuery & " GuestSelected = " & cint(guestID)
    strQuery = strQuery & ", DateSelected = #" & Now() & "#"
    strQuery = strQuery & " WHERE GiftID = " & selectGiftID

    %>


    Ray at work
    Ray at, Oct 20, 2003
    #5
  6. ree

    Ray at Guest

    There was a line-wrap issue there in your newsreader. He was actually
    commenting out the " & ";"" part. At least that's how I interpreted after
    questioning it also.

    Ray at work

    "Randy Rahbar" <rvrahbarAThotmail.com> wrote in message
    news:...
    > > strQuery = strQuery & " WHERE GiftID = " & selectGiftID' &

    >
    > What's with the single quote after selectGiftID?
    >
    > > ";"

    >
    > You might want to lose that too. Assuming selectGiftID is numeric, change
    > the last line to...
    > strQuery = strQuery & " WHERE GiftID = " & selectGiftID
    >
    >
    Ray at, Oct 20, 2003
    #6
  7. ree

    Randy Rahbar Guest

    > There was a line-wrap issue there in your newsreader. He was actually
    > commenting out the " & ";"" part. At least that's how I interpreted after
    > questioning it also.


    Whoops... yeah, that makes more sense. Thanks :)
    Randy Rahbar, Oct 20, 2003
    #7
  8. ree

    ree Guest

    "Aaron Bertrand - MVP" <> wrote in
    news:#:

    >> strQuery = strQuery & ", DateSelected = " & Now()

    >
    > Access requies # to delimit dates, but Access also knows what now()
    > is, so instead of trying to concatenate from ASP, just say
    >
    > strQuery = strQuery & ", DateSelected = Now()"




    Thanks guys but for some reason not doing what I did before strangely work
    on another page.
    ree, Oct 20, 2003
    #8
  9. ree

    ree Guest


    >
    > Dates are delimited with # in Access databases.
    >
    > strQuery = strQuery & ", DateSelected = #" & Now() & "#"
    > strQuery = strQuery & " WHERE GiftID = " & selectGiftID
    >
    > %>



    Thanks guys but for some reason not doing what I did before strangely work
    on another page.
    ree, Oct 20, 2003
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?bWVuc3V1cg==?=

    stupid annoying form error

    =?Utf-8?B?bWVuc3V1cg==?=, Mar 4, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    288
    =?Utf-8?B?bWVuc3V1cg==?=
    Mar 4, 2006
  2. Shawn
    Replies:
    8
    Views:
    1,266
    Thomas Hawtin
    Oct 25, 2006
  3. Jay
    Replies:
    2
    Views:
    1,056
  4. Charles Fox
    Replies:
    56
    Views:
    1,184
    Ben Finney
    Sep 19, 2007
  5. Mark Richards
    Replies:
    3
    Views:
    296
    Tad McClellan
    Nov 18, 2007
Loading...

Share This Page