Connect Classic ASP to Access with a DSN

Last updated: August 27, 2026.

A system DSN stores ODBC settings under a name that ADO can open. Configure it with the ODBC administrator matching the application pool’s architecture.

<%
Dim connection
Set connection = Server.CreateObject("ADODB.Connection")
connection.Open "DSN=example_dsn"
' Use the connection, then close it.
connection.Close
Set connection = Nothing
%>
<%
Const adCmdText = 1
Const adInteger = 3
Const adParamInput = 1
Dim command
Set command = Server.CreateObject("ADODB.Command")
Set command.ActiveConnection = connection
command.CommandType = adCmdText
command.CommandText = "SELECT Make, Model FROM Cars WHERE CarID = ?"
command.Parameters.Append command.CreateParameter("CarID", adInteger, adParamInput, , CLng(Request.QueryString("id")))
%>

Keep the database outside the public directory and grant only required filesystem permissions.

Need to replace an Access-backed application? Explore Microsoft Access replacement options.

admin

admin

Leave a Reply

Your email address will not be published.