Click to See Complete Forum and Search --> : update error, help asap


jrthor2
04-15-2003, 09:23 AM
Can someone please tell me the problem with this update statement? I use the same statement on another part of my site with no problems. I get the following error:

Microsoft JET Database Engine error '80040e14'

Syntax error in UPDATE statement.

/Members/_update.asp, line 41

Here is my code:
Set conn = server.createobject("adodb.connection")
DSNtemp="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("members.mdb")
conn.Open DSNtemp

SQLstmt = "UPDATE MemberList SET "
SQLstmt = SQLstmt & "LastName='" & Trim(Request.Form("last_name")) & "',"
SQLstmt = SQLstmt & "FirstName='" & Trim(Request.Form("first_name")) & "',"
SQLstmt = SQLstmt & "Address1='" & Trim(Request.Form("Address1")) & "',"
SQLstmt = SQLstmt & "Address2='" & Trim(Request.Form("Address2")) & "',"
SQLstmt = SQLstmt & "CityState='" & Trim(Request.Form("city_state")) & "',"
SQLstmt = SQLstmt & "Zip='" & Trim(Request.Form("zip")) & "',"
SQLstmt = SQLstmt & " WHERE ID=" & TRIM(Request.Form("memberid"))
response.write(SQLstmt)
conn.execute(SQLstmt)


conn.Close
Set conn = nothing
Set SQLstmt = nothing

Thanks

DaiWelsh
04-15-2003, 11:18 AM
You have a comma after the last field and before the WHERE so your statement will loook like

.... ,Zip='XXXXX', WHERE .....

which is not valid. Chnage this line

SQLstmt = SQLstmt & "Zip='" & Trim(Request.Form("zip")) & "',"

to

SQLstmt = SQLstmt & "Zip='" & Trim(Request.Form("zip"))

and all should be well :)

HTH,

Dai

jrthor2
04-15-2003, 11:24 AM
duh, thanks alot. My brain is hurting right now :-)

I actually had to do it like this:

SQLstmt = SQLstmt & "Zip='" & Trim(Request.Form("zip")) & "'"

DaiWelsh
04-15-2003, 11:27 AM
of course you did, my bad :)