bairdb Posted January 16, 2006 Share Posted January 16, 2006 I am trying to create a form that will update a database. I took the code off of the Update tutorial here and just changed everything to work with my database but I can't get the update to write to the database, I either get the error that is in there or the page just refreshes and nothing happens. Any help would be appreciated.Form <html><body><%set conn=Server.CreateObject("ADODB.Connection")conn.Provider="Microsoft.Jet.OLEDB.4.0"conn.Open(Server.MapPath("DB/QORSeperated.mdb"))set rs=Server.CreateObject("ADODB.Recordset")rs.open "SELECT * FROM QOR2",conn%><h2>List Database</h2><table border="1" width="100%"><tr><%for each x in rs.Fields response.write("<th>" & (x.name) & "</th>")next%></tr><% do until rs.EOF %><tr><form method="post" action="update.asp"><%for each x in rs.Fields if (x.name)="ID" then%> <td> <input type="submit" name="id" value="<%=x.value%>"> </td> <%else%> <td><%Response.Write(x.value)%></td> <%end ifnext%></form><%rs.MoveNext%></tr><%loopconn.close%></table></body></html> Update Page <html><body><h2>Update Record</h2><%set conn=Server.CreateObject("ADODB.Connection")conn.Provider="Microsoft.Jet.OLEDB.4.0"conn.Open(Server.MapPath("DB/QORSeperated.mdb"))id=Request.Form("ID")if Request.form("Type")<>"" then set rs=Server.CreateObject("ADODB.Recordset") rs.open "SELECT * FROM QOR2 WHERE ID='" & id & "' ORDER BY ID",conn %> <form method="post"> <table> <%for each x in rs.Fields%> <tr> <td><%=x.name%></td> <td><input name="<%=x.name%>" value="<%=x.value%>"></td> <%next%> </tr> </table> <br /><br /> <input type="submit" value="Update record"> </form><%else sql="UPDATE QOR2 SET " sql=sql & "Type='" & Request.Form("Type") & "'," sql=sql & "TotalCLFRDIV='" & Request.Form("TotalCLFRDIV") & "'," sql=sql & "FR='" & Request.Form("FR") & "'," sql=sql & "COMMLINES='" & Request.Form("COMMLINES") & "'," sql=sql & "TimeSlice='" & Request.Form("TimeSlice") & "'," sql=sql & "Quarter='" & Request.Form("Quarter") & "'," sql=sql & " WHERE ID='" & id & "'" on error resume next conn.Execute sql if err<>0 then response.write("No update permissions!") else response.write("Record " & id & " was updated!")end ifend ifconn.close%></body></html> Link to comment Share on other sites More sharing options...
bairdb Posted January 16, 2006 Author Share Posted January 16, 2006 I also tried running this without the on error portion of the code and I get this error. Error Type:Microsoft JET Database Engine (0x80040E14)Syntax error in UPDATE statement.update.asp, line 37 Link to comment Share on other sites More sharing options...
dennisa Posted January 18, 2006 Share Posted January 18, 2006 I also got error with the same type of yours, "syntax error in insert statement"what the ######??somebody help us? Link to comment Share on other sites More sharing options...
netcracker Posted January 19, 2006 Share Posted January 19, 2006 try using get instead of post. <form method="get" action="update.asp"> the "post"method requires "taking" the value with "request.querystring" not "request.form"....I think ...it's a gues... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now