Hello, I've built an ASP series that allows users to view info in a table (MS ACCESS) and they also have an "edit" link listed by the row in the record. When the "edit" is clicked the user is directed to another ASP page that contains a form. The information inside of the form text boxes is the information from the record. The user then can make manual changes to the data and click a submit button. The data is then supposed to be updated by a SQL statement. I keep getting some errors from this step complaining about the SQL statement. I have troubleshot this thing to death. I'm new to SQL update statements and the ever so thorn in the side of quotes and doublequotes. The data in the tables consists of a record id(autonumber, which isn't editable on the form), a userid(text),a password(text by Access Definition, but does contain numbers, ex. "12ms32"
, and an email(text). I will include the ASP code that "does the work" and the error message. Please advise on corrections. Thanks in advance!
ERROR MSG:
Database Errors Occured
UPDATE tblUsers SET UserID='rsmith';Password='rwssmy';Email='rsmith@smithsmachine.com';WHERE ID=24;
Error #-2147217900
Error desc. -> Characters found after end of SQL statement.
ACTUAL CODE:
<%
on error resume next
form_userid=request.form("userID"
form_password=request.form("password"
form_email=request.form("email"
form_ID=request.form("ID"
set conn=server.createobject("ADODB.connection"
conn.provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/db/pics/mbvault.mdb"
form_userid=Replace(form_userid,"'","''"
if instr(lcase(form_userid),"<img"
>0 then
form_userid=""
end if
SQLstmt = "UPDATE tblUsers SET "
SQLstmt = SQLstmt & "UserID='" & form_userid & "';"
SQLstmt = SQLstmt & "Password='" & form_password & "';"
SQLstmt = SQLstmt & "Email='" & form_email & "';"
SQLstmt = SQLstmt & "WHERE ID=" & form_id & ";"
set rs = conn.Execute(SQLStmt)
If err.number>0 then
response.write "VBScript Errors Occured:" & "<P>"
response.write "Error Number=" & err.number & "<p>"
response.write "Error Descr.=" & err.description & "<p>"
response.write "Help Context=" & err.helpcontext & "<p>"
response.write "Help Path=" & err.helppath & "<p>"
response.write "Native Error=" & err.nativeerror & "<p>"
response.write "Source=" & err.source & "<p>"
response.write "SQLState=" & err.sqlstate & "<p>"
end if
if conn.Errors.Count>0 then
response.write "Database Errors Occured" & "<p>"
response.write SQLstmt & "<p>"
for counter= 0 to conn.Errors.Count
response.write "Error #" & conn.Errors(counter).Number & "<p>"
response.write "Error desc. -> " & conn.Errors(counter).Description & "<p>"
next
else
response.write "<b>Everything Went Fine! Record is now UPDATED!</b>"
response.write "<br>" & SQLstmt
end if
rs.close
set rs = nothing
conn.Close
set conn = nothing
%>
Thank you guys for the help!!!
ERROR MSG:
Database Errors Occured
UPDATE tblUsers SET UserID='rsmith';Password='rwssmy';Email='rsmith@smithsmachine.com';WHERE ID=24;
Error #-2147217900
Error desc. -> Characters found after end of SQL statement.
ACTUAL CODE:
<%
on error resume next
form_userid=request.form("userID"
form_password=request.form("password"
form_email=request.form("email"
form_ID=request.form("ID"
set conn=server.createobject("ADODB.connection"
conn.provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/db/pics/mbvault.mdb"
form_userid=Replace(form_userid,"'","''"
if instr(lcase(form_userid),"<img"
form_userid=""
end if
SQLstmt = "UPDATE tblUsers SET "
SQLstmt = SQLstmt & "UserID='" & form_userid & "';"
SQLstmt = SQLstmt & "Password='" & form_password & "';"
SQLstmt = SQLstmt & "Email='" & form_email & "';"
SQLstmt = SQLstmt & "WHERE ID=" & form_id & ";"
set rs = conn.Execute(SQLStmt)
If err.number>0 then
response.write "VBScript Errors Occured:" & "<P>"
response.write "Error Number=" & err.number & "<p>"
response.write "Error Descr.=" & err.description & "<p>"
response.write "Help Context=" & err.helpcontext & "<p>"
response.write "Help Path=" & err.helppath & "<p>"
response.write "Native Error=" & err.nativeerror & "<p>"
response.write "Source=" & err.source & "<p>"
response.write "SQLState=" & err.sqlstate & "<p>"
end if
if conn.Errors.Count>0 then
response.write "Database Errors Occured" & "<p>"
response.write SQLstmt & "<p>"
for counter= 0 to conn.Errors.Count
response.write "Error #" & conn.Errors(counter).Number & "<p>"
response.write "Error desc. -> " & conn.Errors(counter).Description & "<p>"
next
else
response.write "<b>Everything Went Fine! Record is now UPDATED!</b>"
response.write "<br>" & SQLstmt
end if
rs.close
set rs = nothing
conn.Close
set conn = nothing
%>
Thank you guys for the help!!!