ASP Forum
ADO Add Record Problems
steveaj | Posted 12:44am 13. October 2010 Server Time |

I have problem adding a record into my database from a web browser. I have written the html page and the action page as follows;
Here is the form code:
<html>
<body>
<form method="post" action="demo_add.asp">
<table>
<tr>
<td>S/No:</td>
<td><input name="id"></td>
</tr><tr>
<td>Name:</td>
<td><input name="name"></td>
</tr><tr>
<td>Phone Number:</td>
<td><input name="foneno"></td>
</tr>
</table>
<br /><br />
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</form>
</body>
</html>
and here is the form action code (demo_add.asp):
<html>
<body>
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "C:\Inetpub\wwwroot\My_Web\Example\Contacts.mdb"
set rs=Server.CreateObject("ADODB.recordset")
sql="INSERT INTO Phone_Numbers (id,name,"
sql=sql & "foneno)"
sql=sql & " VALUES "
sql=sql & "('" & Request.Form("id") & "',"
sql=sql & "'" & Request.Form("name") & "',"
sql=sql & "'" & Request.Form("foneno") & "')"
on error resume next
conn.Execute sql,recaffected
if err<>0 then
Response.Write("No update permissions!")
else
Response.Write("<h3>" & recaffected & " record added</h3>")
end if
conn.close
%>
</body>
</html>
Each time I try to add a record from the browser, it would retrurn the error message (No Update Permission).
Please I want folks to help me look carefully at the code and tell me all the possible errors in the code. Thanks


Reply to Post ADO Add Record Problems



Back to Forum Page