Jump to content

Unable to add to Database


Paulhar
 Share

Recommended Posts

Hi All,Total newbie to ASP here so please don’t laugh. I’ve modified the sample files on this site to try and create a page (register.htm) where a user can enter some personal details which should then be added to a database (test.mdb).Clicking the ‘Add New’ button opens the member_add.asp page and then, for some reason, I get asked if I want to open or save this asp file. If I choose ‘Open’ the page flickers and nothing else happens – the new record is not added to the database.Register.htm<p>Enter Personal details to be added to the database</p><form method="post" action="c:\database_test\member_add.asp" target="_blank"><table><tr><td>First Name:</td><td><input name="Firstname"></td></tr><tr><td>Surname:</td><td><input name="Surname"></td></tr><tr><td>User Name:</td><td><input name="Username"></td></tr><tr><td>Password</td><td><input name="Pwd"></td></tr><tr></table><br /><br /><input type="submit" value="Add New"> <input type="reset" value="Cancel"></form>member_add.asp<html><body><%set conn=Server.CreateObject("ADODB.Connection")conn.Provider="Microsoft.Jet.OLEDB.4.0"conn.Open "c:\database_test\test.mdb"sql="INSERT INTO Members (Username, Firstname, Surname, Pwd) VALUES "sql=sql & "('" & Request.Form("Username") & "',"sql=sql & "'" & Request.Form("Firstname") & "',"sql=sql & "'" & Request.Form("Surname") & "',"sql=sql & "'" & Request.Form("Pwd") & "')"on error resume nextconn.Execute sql,recaffectedif err<>0 then Response.Write("No update permissions!")else Response.Write("<h3>" & recaffected & " record added</h3>")end ifconn.close%></body></html>Any help much appreciated.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...