468,534 Members | 2,264 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

ASP and Databases

By Robert Murdock
Programmer, Darpac Inc.

The ASP data access component is one of the most powerfull features of ASP. With this component you are able to interface your database(s) directly with your webserver.

Database access in ASP is, or can be, very complex. We are going to focus on just a few objects to help you get started with the basics and you can then move forward from there.

Getting started:

For our examples we will be using Microsoft's Access. Note: I test with '97 version of Access. I have been told way we connect does not work with Access 2000. I will test and provide a solutions (if there is one) in the next artical on database access.

The first thing you will need to do is to plan and set up your database. This step should be planned and well thought out. For our example we will be creating an online contact book. Here is what our database will look like:

Name Character string of 50 characters max.
Email Character string of 50 characters max.
Phone Character string of 15 characters max.

Now it is time to create the DB. Start up Access and click on the radial button that shows "Blank Access database". Next, enter the file name of "cdemo" and click the "create" button. You should now see a box with differnt create options. Choose "Create table in design veiw". Now we are ready to creace the db fields.

In the first box in the upper left hand side enter "Name". Press enter and the next field will highlight. About halfway down your screen you will see a tab that says, "general". Under that is a "Field size 50". That is fine. Do the same and add the fields "Email" and Phone". Be sure to change the Field Size for Phone to 15.

When you have the 3 fields in click the save icon on the menu bar. Change the default name of Table1 to "tblContact". Access will ask if you want to create a primary contact. Choose yes. You now have a DB that you can use.

  Connect to Database »