|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
hi!
I m trying to update the data in Ms Access Database This is my code: <html> <% set conn = server.createobject("adodb.connection") DSNtemp="DRIVER={Microsoft Access Driver (*.mdb)}; " DSNtemp=dsntemp & "DBQ=" & server.mappath("ApplicantDetails.mdb") conn.Open DSNtemp, SQLstmt SQLstmt = "Update Applicant SET " SQLstmt = SQLstmt & "UserName='" & TRIM(Request.Form("uname")) & "', " SQLstmt = SQLstmt & "Password='" & TRIM(Request.Form("pass")) & "', " SQLstmt = SQLstmt & "FirstName='" & TRIM(Request.Form("fst")) & "', " SQLstmt = SQLstmt & "LastName='" & TRIM(Request.Form("lst")) & "', " SQLstmt = SQLstmt & "Address='" & TRIM(Request.Form("add"))& "', " SQLstmt = SQLstmt & " MobileNo='" & TRIM(Request.Form("mob"))& "', " SQLstmt = SQLstmt & " Email='" & TRIM(Request.Form("email"))& "', " SQLstmt = SQLstmt & " Occupation='" & TRIM(Request.Form("occ"))& "', " SQLstmt = SQLstmt & " WHERE IdNo='" & TRIM(Request.Form("id"))& "'," conn.Execute(SQLstmt)------>Error Response.Write "Your account Information has modified successfuly" %> </html> Error Type: Microsoft OLE DB Provider for ODBC Drivers (0x80040E14) [Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE statement. Please help me to solve the error. |
|
#2
|
||||
|
||||
|
Remove the red commas
Code:
SQLstmt = SQLstmt & " Occupation='" & TRIM(Request.Form("occ"))& "', "
SQLstmt = SQLstmt & " WHERE IdNo='" & TRIM(Request.Form("id"))& "',"
|
|
#3
|
|||
|
|||
|
If I removed the red commas then my code is as follows:
<html> <% set conn = server.createobject("adodb.connection") DSNtemp="DRIVER={Microsoft Access Driver (*.mdb)}; " DSNtemp=dsntemp & "DBQ=" & server.mappath("ApplicantDetails.mdb") conn.Open DSNtemp, SQLstmt SQLstmt = "Update Applicant SET " SQLstmt = SQLstmt & "UserName='" & TRIM(Request.Form("uname")) & "'" SQLstmt = SQLstmt & "Password='" & TRIM(Request.Form("pass")) & "'" SQLstmt = SQLstmt & "FirstName='" & TRIM(Request.Form("fst")) & "'" SQLstmt = SQLstmt & "LastName='" & TRIM(Request.Form("lst")) & "'" SQLstmt = SQLstmt & "Address='" & TRIM(Request.Form("add"))& "'" SQLstmt = SQLstmt & " MobileNo='" & TRIM(Request.Form("mob"))& "'," SQLstmt = SQLstmt & " Email='" & TRIM(Request.Form("email"))& "'" SQLstmt = SQLstmt & " Occupation='" & TRIM(Request.Form("occ"))& "'" SQLstmt = SQLstmt & " WHERE IdNo='" & TRIM(Request.Form("id"))& "'" conn.Execute(SQLstmt) Response.Write "Your account Information has modified successfuly" %> </html> But still i m getting ERROR as: Error Type: Microsoft OLE DB Provider for ODBC Drivers (0x80040E14) [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression ''dae2'Password='abcdef'FirstName='dsfa'LastName=' fsdf'Address='fdsfs' MobileNo='57877''. |
|
#4
|
||||
|
||||
|
You only need to remove the exact ones I specified, not all of them.
|
|
#5
|
|||
|
|||
|
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E07) [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression. |
|
#6
|
||||
|
||||
|
We'll need to see the query
|
|
#7
|
|||
|
|||
|
My code is as follows:
<html> <% set conn = server.createobject("adodb.connection") DSNtemp="DRIVER={Microsoft Access Driver (*.mdb)}; " DSNtemp=dsntemp & "DBQ=" & server.mappath("ApplicantDetails.mdb") conn.Open DSNtemp, SQLstmt SQLstmt = "Update Applicant SET " SQLstmt = SQLstmt & "UserName='" & TRIM(Request.Form("uname")) & "'," SQLstmt = SQLstmt & "Password='" & TRIM(Request.Form("pass")) & "'," SQLstmt = SQLstmt & "FirstName='" & TRIM(Request.Form("fst")) & "'," SQLstmt = SQLstmt & "LastName='" & TRIM(Request.Form("lst")) & "'," SQLstmt = SQLstmt & "Address='" & TRIM(Request.Form("add"))& "'," SQLstmt = SQLstmt & " MobileNo='" & TRIM(Request.Form("mob"))& "'," SQLstmt = SQLstmt & " Email='" & TRIM(Request.Form("email"))& "'," SQLstmt = SQLstmt & " Occupation='" & TRIM(Request.Form("occ"))& "'" SQLstmt = SQLstmt & " WHERE IdNo='" & TRIM(Request.Form("id"))& "'" conn.Execute(SQLstmt) Response.Write "Your account Information has modified successfuly" %> </html> If anyone knows whts wrong with it please help me to solve it. Its urgent! Last edited by Sharmishtha : July 13th, 2004 at 08:27 AM. Reason: to change some text |
|
#8
|
||||
|
||||
|
The first thing you should always do when debugging error messages is to print the string to screen that's causing you problems... in this case, your SQL string...so, before you execute the statement:
Code:
response.write(SQLstmt) conn.Execute(SQLstmt) |
|
#9
|
|||
|
|||
|
Are some of your field numeric and not text? If so, no single quotes should be used on those.
What happens if you try this? SQLstmt = SQLstmt & " WHERE IdNo=" & TRIM(Request.Form("id")) If it doesn't work, do a response.write as stumpy say. |
|
#10
|
|||
|
|||
|
Hi!
Thanx to stumpy & EiSa. My code is working now! |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft SQL Server > Syntax error in UPDATE statement. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|