PDA

View Full Version : Insert Into Synatx error


YenRaven
08-21-2006, 04:05 PM
I just know im makeing a stupid mistake but no matter what i try (reserverd words and such) i have no luck debuging this one line of code:

set Exe = oConn.Execute("INSERT INTO sales_reps SET (username, vpassword, first_name, last_name, address, city, vstate, zip, home_phone, cell_phone, email, location_tag, ses_number) VALUES ('"& username &"', '"& password &"', '"& first_name &"', '"& last_name &"', '"& Address &"', '"& vCity &"', '"& vState &"', '"& Zip &"', '"& HomePhone &"', '"& CellPhone &"', '"& Email &"', '"& LocationTag &"', '"& SESNumber &"')")

the error it returns is a syntax error:

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.

/testindc/sunrise/save_new_rep.asp, line 31

all names were copied and pasted form the originals. if anyone sees my mistake any help would be greatly apprecieated.

mehere
08-21-2006, 04:44 PM
try using a response.Write to see how your string is being built
strSQL = "INSERT INTO sales_reps (username, vpassword, " & _
"first_name, last_name, address, city, vstate, zip, home_phone, cell_phone, " & _
"email, location_tag, ses_number) VALUES ('"& username &"', " & _
"'" & password &"', '"& first_name &"', '"& last_name &"', '"& Address &"', " & _
"'" & vCity &"', '"& vState &"', '"& Zip &"', '"& HomePhone &"', '"& CellPhone &"', " & _
"'" & Email &"', '"& LocationTag &"', '"& SESNumber &"')"
response.Write(strSQL)
response.End
set Exe = oConn.Execute(strSQL)
it generally makes it easier to see the error. also i removed the SET keyword. it's not needed for inserts only updates.

YenRaven
08-21-2006, 04:48 PM
Already tried a response.write but everything looks fine. no nulls, all ' closed. here is a sample output:

INSERT INTO sales_reps SET (username, vpassword, first_name, last_name, address, city, vstate, zip, home_phone, cell_phone, email, location_tag, ses_number) VALUES ('bvilla', '12870C', 'Bob', 'Villa', '1987 Walnut Drive', 'New York', 'NY', '77645', '(775)877-0776', ' ', 'Bob@hotmail.com', 'NY', '1000')

YenRaven
08-21-2006, 04:53 PM
nvm just checked the post i submitted to the sql guys and found out that SET is not proper for insert into. stupid me :confused: