Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linking Database

Status
Not open for further replies.

willit

Programmer
Aug 10, 2003
6
0
0
US
I build databases and websites but have never linked the two. I handcoded websites until a few months back when I broke down and bought Dreamweaver. I have a business that I built both a website and a database for and would like to link them together so when a customer completes a form on the website it will automatically update the database. Currently, when the form is submitted it is emailed and the business owner manually enters the info into the database. The database is Access.
My question is: Is ASP the technology used to do something like this and how is the best way to learn how to do it? Can anyone give me a brief overview of what actually happens when the customer submits a form and how the database automatically updates?
This is not something I have to do but something I want to learn to do so any insight would be appreciated.
 
You can definitely do this by ASP. Let's look at it step by step.

1. Make the form send the form data to the ASP file
This is easy. While declaring the form by <form> tag, give action=&quot;savetodb.asp&quot; as the target file.

You can submit data is two ways... method=post will submit the data to the ASP, but the data will not be displayed in your Address bar, method=get will do the same, but the values that are passed to the ASP will be displayed in the address bar.

2. In the ASP, connect to the database by creating a connection object.

Set con=Server.CreateObject(&quot;Adodb.Connection&quot;)
open this connection with the correct provide e.g. DSN or Access driver. e.g.

con.open &quot;DSN=testdb&quot;

3. In the ASP, create & open a recordset based on the above connection, on the table where data will be updated.

Set rsTest=Server.CreateObject(&quot;Adodb.Recordset&quot;)
rsTest.Open &quot;myTable&quot;,con,3,3

4. Now that you have the table already open, you can easily read the values sent from the form and save to the table e.g.

rsTest.AddNew 'adding a new record

'Assign the values from the form to this new record
rsTest(&quot;Name&quot;)=Response.Form(&quot;Name&quot;)
rsTest(&quot;Email&quot;)=Response.Form(&quot;Email&quot;)

'Update this new record i.e. write to the actual table in DB
rsTest.Upate

Request.Form is used with method=post in Form tag, while Request.Querystring is used in method=get.

That's it!!
You have added data to the table from the Form.

If you still need more info, search for FAQs and you will find plenty.
 
Thanks for the explanation!! As soon as I get the time I will try to work through it and see if I can get it to work. I am really excited about learning to do this. THANKS!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top