472,119 Members | 1,973 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,119 software developers and data experts.

ASP learner scratching head

Hi All,

I am ASP beginner and seeking some help please. I am using online tutorial to learn. However been having this problem last 2 days. If I get any help, would be greatly appreciated to learner like me. I have 3 files listed codes for them below. I am creating basic addressbook which reads input from first file (addressbook_form.htm). I am using 2nd file (add_to_addressbook.asp) to post read-in data to 3rd file which is (addressbook.asp). I have gone thru each and every line of code but cannot get 'updated' addressbook.asp to work and show new entry being added. Again, any help be very helpful. please tell me what am i doing wrong here?

================================================== ===
addressbook_form.htm

<html>
<head>
<title>Adddressbook Form</title>
</head>
<body bgcolor="white" text="black">
<!-- Begin form code -->
<form name="form" method="post" action="add_to_addressbook.asp">
First Name: <input type="text" name="firstname" maxlength="20">
<br>
Last Name: <input type="text" name="lastname" maxlength="20">
<br>
Address: <input type="text" name="address" maxlength="20">
<br>
City: <input type="text" name="city" maxlength="20">
<br>
State: <input type="text" name="state" maxlength="20">
<br>
Zip: <input type="text" name="zip" maxlength="20">
<br>
Country: <input type="text" name="country" maxlength="20">
<br>
Email: <input type="text" name="email" maxlength="20">
<br>
Home Phone: <input type="text" name="homephone" maxlength="20">
<br>
Work Phone: <input type="text" name="workphone" maxlength="20">
<br>
Mobile Phone: <input type="text" name="mobilephone" maxlength="20">
<br>
<input type="submit" name="Submit" value="Submit">
</form>
<!-- End form code -->
</body>
</html>



================================================== =====
add_to_addressbook.asp


<%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsAddComments 'Holds the recordset for the new record to be added to the database
Dim strSQL 'Holds the SQL query for the database

'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("addressbook.mdb")

'Create an ADO recordset object
Set rsAddComments = Server.CreateObject("ADODB.Recordset")

'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT FirstName, LastName, Address, City, State, Zip, Country, Email, HomePhone, WorkPhone, MobilePhone FROM addressbook;"

'Set the cursor type we are using so we can navigate through the recordset
rsAddComments.CursorType = 2

'Set the lock type so that the record is locked by ADO when it is updated
rsAddComments.LockType = 3

'Open the addressbook table using the SQL query held in the strSQL varaiable
rsAddComments.Open strSQL, adoCon

'Tell the recordset we are adding a new record to it
rsAddComments.AddNew

'Add a new record to the recordset
rsAddComments.Fields("FirstName") = Request.Form("firstname")
rsAddComments.Fields("LastName") = Request.Form("lastname")
rsAddComments.Fields("Address") = Request.Form("address")
rsAddComments.Fields("City") = Request.Form("city")
rsAddComments.Fields("State") = Request.Form("state")
rsAddComments.Fields("Zip") = Request.Form("zip")
rsAddComments.Fields("Country") = Request.Form("country")
rsAddComments.Fields("Email") = Request.Form("email")
rsAddComments.Fields("HomePhone") = Request.Form("homephone")
rsAddComments.Fields("WorkPhone") = Request.Form("workphone")
rsAddComments.Fields("MobilePhone") = Request.Form("mobilephone")

'Write the updated recordset to the database
rsAddComments.Update

'Reset server objects
rsAddComments.Close
Set rsAddComments = Nothing
Set adoCon = Nothing

'Redirect to the addressbook.asp page
Response.Redirect "addressbook.asp"
%>



================================================== ======
addressbook.asp

<html>
<head>
<title>Addressbook</title>
</head>
<body bgcolor="white" text="black">
<%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsAddressbook 'Holds the recordset for the records in the database
Dim strSQL 'Holds the SQL query for the database

'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("addressbook.mdb")

'Create an ADO recordset object
Set rsAddressbook = Server.CreateObject("ADODB.Recordset")

'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT FirstName, LastName, Address, City, State, Zip, Country, Email, HomePhone, WorkPhone, MobilePhone FROM addressbook;"

'Open the recordset with the SQL query
rsAddressbook.Open strSQL, adoCon

'Loop through the recordset
Do While not rsAddressbook.EOF

'Write the HTML to display the current record in the recordset
Response.Write ("<br>")
Response.Write (rsAddressbook("FirstName"))
Response.Write ("<br>")
Response.Write (rsAddressbook("LastName"))
Response.Write ("<br>")
Response.Write (rsAddressbook("Address"))
Response.Write ("<br>")
Response.Write (rsAddressbook("City"))
Response.Write ("<br>")
Response.Write (rsAddressbook("State"))
Response.Write ("<br>")
Response.Write (rsAddressbook("Zip"))
Response.Write ("<br>")
Response.Write (rsAddressbook("Country"))
Response.Write ("<br>")
Response.Write (rsAddressbook("Email"))
Response.Write ("<br>")
Response.Write (rsAddressbook("HomePhone"))
Response.Write ("<br>")
Response.Write (rsAddressbook("WorkPhone"))
Response.Write ("<br>")
Response.Write (rsAddressbook("MobilePhone"))
Response.Write ("<br>")

'Move to the next record in the recordset
rsAddressbook.MoveNext

Loop

'Reset server objects
rsAddressbook.Close
Set rsAddressbook = Nothing
Set adoCon = Nothing
%>
</body>
</html>
Feb 26 '07 #1
2 1385
OK, update....I just uploaded ALL 4 files, including .mdb to my webspace and tried to run and test out. It WORKED, YES IT WORKED! So there MUST BE something wrong with my IIS? I have no clue as I said earlier I am newbee in this field so any suggestions? All I did is installed IIS from my WINDOWS XP cd and set permission on files I am workign on FULL CONTROL, under security tab from properties. Do I need to tweak anything else to test out my asp code locally? currently I am using http://localhost/......
thanks a bunch!
Feb 26 '07 #2
clain
79
Buddy.... use to set up

intemanager

ie go to run, type "intmgr" and click ok....
in that chose your virtual directory about set all permissions such as querry,read write,exicute browse...
now hit apply..

yahooooo enjoy
happy coding..

Clain4u@yahoo.co.in
Feb 27 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Simon | last post: by
reply views Thread by Simon | last post: by
reply views Thread by Simon | last post: by
9 posts views Thread by Silas Justiniano | last post: by
46 posts views Thread by pkirk25 | last post: by
2 posts views Thread by KiranJyothi | last post: by
1 post views Thread by bill.wu | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.