Connect to MS Access database from ASP

Connecting to MS Access database from Classic ASP can be accomplished in several ways. You can connect using OLEDB DSN-less connection, you can connect using ODBC connection or you can use DSN.

1. Connect to a Microsoft Access Database from ASP using a DSN

Set oConnection = Server.CreateObject("ADODB.Connection")

oConnection.Open "DSN=;UID=;PWD="

oConnection.Close

The ASP connection example above is very simple and all you need to do is to create a DSN for your MS Access database.

2. Connect to a Microsoft Access Database from ASP using DSN-less ODBC connection

Set oConnection = Server.CreateObject("ADODB.Connection")

oConnection.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" &

Server.MapPath("") & ";UID=;PWD="

oConnection.Close

Set oConnection = Nothing

This ASP MS Access connection example doesn’t require DSN, but requires that you have Microsoft Access Driver installed on your computer/server.

3. Connect to a Microsoft Access Database from ASP using DSN-less OLEDB connection

Set oConnection = Server.CreateObject("ADODB.Connection")

oConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &

Server.MapPath("") & ";"

oConnection.Close

Set oConnection = Nothing

This MS Access ASP connection example requires only the OLEDB provider to work.