JetHost Logo
AMHosting is now part of the JetHost family!
AMHosting has joined JetHost to bring you faster infrastructure, enhanced security, and modern tools - backed by a team with 25+ years of hosting experience.
Read the full story here in the official blog post.

WebsiteKnowledge Base

Access Database Connections

Without DSN
<%
Set Cnn = Server.CreateObject("ADODB.Connection")
Cnn.open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=c:mydatabase.mdb"
%>
OLE DB
<%
Set Cnn = Server.CreateObject("ADODB.Connection")
Cnn.open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=c:mydatabase.mdb"
%>
Using a physical path as a reference
<%
Set Conn = Server.CreateObject("ADODB.Connection")
DSNtest="DRIVER={Microsoft Access Driver (*.mdb)}; "
DSNtest=dsntest & "DBQ=c:mydatabase.mdb"
Conn.Open DSNtest
%>
Using Server.MapPath
NOTE: Server.MapPath is the path from the Web server root. By default, this is C:InetpubWwwroot.
<%
Set Conn = Server.CreateObject("ADODB.Connection")
DSNtest="DRIVER={Microsoft Access Driver (*.mdb)}; "
DSNtest=dsntest & "DBQ=" & Server.MapPath("/databases/mydatabase.mdb")
Conn.Open DSNtest
%>