Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax error in INSERT INTO statement. 1

Status
Not open for further replies.

A1Pat

IS-IT--Management
Jun 7, 2004
454
US
hi all,
I'm getting this error:

Microsoft JET Database Engine error '80040e14'

Syntax error in INSERT INTO statement.

and this is where the error indicates,
Code:
sql = "INSERT INTO tblCustomers(custName, password, idLoc, channelNo, active) VALUES(" & _
		"'" & custname & "', '" & password & "', " & idLoc & ", '" & channelNo & "', " & active & ")"
	objConn.Execute sql

the weird thing is that it's working OK when I tested in my work's server, but not in my friend's server where I actually want it to be. Also, the same error appears when I tested locally utilizing localhost.

Please help!
 
Pat, did you try to response.write your SQL statement before you attempt to execute it? It's possible (I've had it happen to me before) that either your idLoc or channel values are blank which would cause a syntax error.

monksnake, that indicates that he's carrying his statement to his next line. It's the equivalent to:
Code:
sql = "INSERT INTO tblCustomers(custName, password, idLoc, channelNo, active) VALUES("
sql = sql & "'" & custname & "', '" & password & "', " & idLoc & ", '" & channelNo & "', " & active & ")"
    objConn.Execute sql

------------------------------------------------------------------------------------------------------------------------
"Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."
- Winston Churchill
 
try this:

Code:
sql = "INSERT INTO tblCustomers(custName, [password], idLoc, channelNo, [active]) VALUES(" & _
        "'" & custname & "', '" & password & "', " & idLoc & ", '" & channelNo & "', " & active & ")"
    objConn.Execute sql

-DNG
 
Hello Chopstik, here are the response.write info I tested:

custname: Patrick
password: 123
idLoc: 1
channelNo: 1
active: 0

 
Thank you DotNetGnat, you did it!!!

the [] around the password and active saved the day. I guessed this is used for reserved words, isn't it?
 
I think I see the problem.

Is password and/or channelNo defined as numeric in your database?

In your statement, you are treating them as strings.

channelNo is my guess, should be numeric.

[monkey][snake] <.
 
actually monksnake, my channelNo is string because it contents my checkbox values which allow more than 1 channel saving.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top