Jump to content

Unable to add to Database


Paulhar

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

<form method="post" action="c:\database_test\member_add.asp" target="_blank">You need to access ASP pages via HTTP, using a file path won't work. They need to be accessed through a web server in order for the ASP code to run.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...