Annoying syntax error

R

ree

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
 
A

Aaron Bertrand - MVP

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
 
R

Randy Rahbar

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
 
R

Ray at

ree said:
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
 
R

Ray at

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
 
R

Randy Rahbar

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 :)
 
R

ree

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.
 
R

ree

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.
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top