"hello_access.asp" - MS Access Example

This section provides a tutorial example on how to connect ASP script pages to an MS Access database directly without using ODBC.

Here is what I did to test those steps described in the previous section:

I ran MS Access. Created a blank database file called: "hello.mdb". Then created a table called "message" in the database. In the "message" table, I added one field called "text".

Before closing the database file, I inserted one row in the "message" table with "Hello world!".

Then I copied "hello.mdb" to my local IIS server as "c:\inetpub\wwwroot\cgi-bin\hello.mdb".

My ASP script for this test was very simple, hello_access.asp:

<script language="vbscript" runat="server">
'  hello_access.asp
'  Copyright (c) 2005 by Dr. Herong Yang, http://www.herongyang.com/

   Set oConn = Server.CreateObject("ADODB.Connection")
   oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
      Server.MapPath("/cgi-bin/hello.mdb")
   Set oRes = oConn.Execute("SELECT * FROM message")

   Response.write(oRes("text"))

   oRes.close
   oConn.close 
</script>

This script was also copied to my local IIS server as "c:\inetpub\wwwroot\hello_access.asp".

Then I opened Internet Explorer with http://localhost/hello_access.asp. I got:

Hello world!

Working, right?

Notes on this test:

Table of Contents

 About This Book

 ASP (Active Server Pages) Introduction

 IIS (Internet Information Services) 5.0

 MS Script Debugger

 VBScript Language

 ASP Built-in Run-time Objects

 ASP Session

 Creating and Managing Cookies

 Managing Sessions with and without Cookies

 scrrun.dll - Scripting Runtime DLL

 Managing Response Header Lines

 Calculation Speed and Response Time

 ADO (ActiveX Data Object) DLL

Working with MS Access Database

 Connecting ASP Pages to MS Access Databases

"hello_access.asp" - MS Access Example

 Persisting Data to MS Access Databases

 Running "insert_access.asp"

 Protecting Data in SQL Statements

 Protecting Data in SQL Statements - Test Script

 Guest Book Application Example

 References

 Full Version in PDF/EPUB