Syntax error in INSERT INTO statement

S

SAM

I got the syntax error message when I tried to insert the value in the table.

SQL12="INSERT into SSUsers values('"_
& Request.QueryString("UserID")& "','"_
& Request.QueryString("UName")& "','"_
& Request.QueryString("UAddress")& "','"_
& Request.QueryString("UCity")& "','"_
& Request.QueryString("UState")& "',"_
& Request.QueryString("UZip")& ","_
& Request.QueryString("UCreditCardNum")& ",'"_
& Request.QueryString("UExpDate")& "','"_
& Request.QueryString("UPassword")& "','"_
& Request.QueryString("CUPassword")& "','"_
& Request.QueryString("UEmail")& "')"
cn.Execute SQL12

UZip & UCreditCardNum are integer type, UExpDate is date/time & others are
txt fields. I am stuck in this problem, can someone help me. I really
appreciate that.

Thanks.
 
D

Douglas J. Steele

Dates need to be delimited with # characters. As well, they should be in
mm/dd/yyyy format, regardless of what the Short Date format has been set to
on the machine. (Okay, that's not strictly true: any unambiguous format such
as dd mmm yyyy or yyyy-mm-dd will work. The point is, you cannot use
dd/mm/yyyy format and expect it to work for the first 12 days of each month)
 
S

SAM

Still didn't work. Can you help me to find out what's missing.
# " & Format(Request.QueryString("UExpDate"),"mm/dd/yyyy")& " #

Thank.
 
G

Gijs Beukenoot

Na rijp beraad schreef SAM :
I got the syntax error message when I tried to insert the value in the table.

SQL12="INSERT into SSUsers values('"_
& Request.QueryString("UserID")& "','"_
& Request.QueryString("UName")& "','"_
& Request.QueryString("UAddress")& "','"_
& Request.QueryString("UCity")& "','"_
& Request.QueryString("UState")& "',"_
& Request.QueryString("UZip")& ","_
& Request.QueryString("UCreditCardNum")& ",'"_
& Request.QueryString("UExpDate")& "','"_
& Request.QueryString("UPassword")& "','"_
& Request.QueryString("CUPassword")& "','"_
& Request.QueryString("UEmail")& "')"
cn.Execute SQL12

UZip & UCreditCardNum are integer type, UExpDate is date/time & others are
txt fields. I am stuck in this problem, can someone help me. I really
appreciate that.

Thanks.

Was this a copy and paste? If so, add a space between the ) and the &
as in :
& Request.QueryString("UPassword") & "','"_
 
D

Douglas J. Steele

Before the cn.Execute SQL12 statement, put a Debug.Print SQL12. Look at
what's printed in the Immediate Window. Does it look right?

Personally, I never use INSERT INTO without explicitly listing the fields,
just to be positive that the values I'm supplying and the fields do line up:

SQL12="INSERT into SSUsers (" _
& "Field1, Field2, Field3, Field4, " _
& "Field5, Field6, Field7, Field8, " _
& "Field9, Field10, Field11) values('"_
& Request.QueryString("UserID")& "','"_
& Request.QueryString("UName")& "','"_
& Request.QueryString("UAddress")& "','"_
& Request.QueryString("UCity")& "','"_
& Request.QueryString("UState")& "',"_
& Request.QueryString("UZip")& ","_
& Request.QueryString("UCreditCardNum")& ", #"_
& Request.QueryString("UExpDate")& "','"_
& Format(Request.QueryString("UExpDate"),"mm/dd/yyyy")& "#, '" _
& Request.QueryString("UPassword")& "','"_
& Request.QueryString("CUPassword")& "','"_
& Request.QueryString("UEmail")& "')"
cn.Execute SQL12
 

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

Top