ASP Tutorials - Herong's Tutorial Notes
Dr. Herong Yang, Version 4.11

Using MS Access Databases

Part:   1  2  3  4  5 

ASP Tutorials - Herong's Tutorial Notes © Dr. Herong Yang

hyBook - Guestbook Application

Using MS Access Databases

ActiveX Data Object (ADO)

Controlling Response Header Lines

Microsoft Scripting Runtime DLL

Using Cookies

ASP Sessions

ASP Objects

Microsoft Script Debugger

Internet Information Services (IIS)

... Table of Contents

(Continued from previous part...)

Of course, you need to create a new table called "Order" in the "hello.mdb" before running this script. The "Order" must have the following fields:

ID - "Autonumber" type
Item - "Text" type
Quantity - "Number" type
Date - "Date/Time" type

Run this script with Internet Explorer, you should see a blank form. Enter a set of good values, like:

Item: Coke
Quantity: 3
Date: 12/25/2020

Then press the "Submit" button. You will see the page comes back again with one row display the values you entered below the form.

The second test you can do is to enter some protected characters in the values, like:

Item: Today's paper
Quantity: 1
Date: #25/10/2020#

The script should have no problem to insert those values into the database.

Another test you can do is to enter some bad values, like:

Item: Milk
Quantity: 2L
Date: 12/25/2020

This time, you will get a crash page with an error: "Microsoft VBScript runtime (0x800A000D), Type mismatch: 'Clng'"

As you can see, my script does not have any logic for type checking. I will leave it to you to improve the script in this area.

Conclusion

  • Connecting to an MS Access file requires no ODBC setting.
  • Inserting data to MS Access file requires "write" permission to file for the Internet Guest account.
  • MS Access string and date values need to be quoted. The quoting character must be protected if it appears in the value.
  • MS Access has many reserved word. If you use them as table names or field names, you must enclose them in "[]".

Part:   1  2  3  4  5 

Dr. Herong Yang, updated in 2005
ASP Tutorials - Herong's Tutorial Notes - Using MS Access Databases