Jump to content

How Do I? Ado Help


khrishnabrown
 Share

Recommended Posts

I created a database using access and I made a form to fill out and enter the informating into the database. The form page is khrishnabrown.info/form.aspI then created a page to add the information called addinfo.asp, the code is: (i got the code from this ado example http://www.w3schools.com/ado/ado_add.asp)<% @language="vbscript" %><html><body><%set conn=Server.CreateObject("ADODB.Connection")conn.Provider="Microsoft.Jet.OLEDB.4.0"conn.Open "/private/contact1.mdb"sql="INSERT INTO tblUsers (UID,PWD,Email"sql=sql & "UID,PWD,Email)"sql=sql & " VALUES "sql=sql & "('" & Request.Form("UID") & "',"sql=sql & "'" & Request.Form("PWD") & "',"sql=sql & "'" & Request.Form("Email") & "')"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> Is there something wrong with the code. my database's name is contact1.mdb which is in a folder called private. The title of the table is tblUsers. The columns are UID, PWD,Email.any help?

Link to comment
Share on other sites

Are you getting any errors? The path to the database is the only thing that might cause a problem, it looks like you're giving it a web-relative path since it starts with a slash. Try giving it the full local filesystem path instead.
But i'm running everything from the hosting site. The .mdb file is in a folder named private in the files section of my hosting account.
Link to comment
Share on other sites

Starting the path with a slash means that you want to start at the web root. Your MDB probably isn't in the web root. If you want to find the path, save this file as path.asp and run it:

<%@LANGUAGE="Jscript"%><%Response.Write(Server.MapPath("path.asp"));%>

That will print the full local filesystem path, you can probably use that to figure out where your MDB is. Or, you can give Server.MapPath a relative path to your MDB, and it will generate the absolute path for it:

<%@LANGUAGE="Jscript"%><%Response.Write(Server.MapPath("../../private/db.mdb"));%>

The filename you give it doesn't need to exist, it just builds the full path for a file with that name.

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...