Dashboard Shop Ask a question
Log in
Knowledge base

Can not connect to MS Access database (Classic ASP)

Our hosting platform supports connections to MS Access databases using DSN-less connection strings. We do not use System DSNs (Data Source Names) because DSN-less connections are faster, more reliable, and avoid naming conflicts on shared servers.

The Connection String

The most common cause of connection errors is an incorrect file path. Because your website runs on a shared server structure, you cannot use a hardcoded physical path (e.g., C:\Websites\MySite\db.mdb). Instead, you must use Server.MapPath to resolve the location dynamically relative to your website root.

Example Code

Assuming your database is named TestDB.mdb and is located in a subfolder named Database, use the following code in your ASP pages:

<%
Dim DbConnection, ConnectionString, DbPath

' 1. Resolve the physical path
DbPath = Server.MapPath("Database\TestDB.mdb")

' 2. Define the connection string (DSN-less)
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DbPath

' 3. Open the connection
Set DbConnection = Server.CreateObject("ADODB.Connection")
DbConnection.Open ConnectionString
%>

Troubleshooting Common Issues

  • "Operation must use an updateable query": This error occurs if your script tries to write to the database (INSERT/UPDATE) but the folder does not have the correct permissions. You must go to the File manager, select the folder containing your database, and grant Write permissions to the web user.
  • "Provider cannot be found" (32-bit vs 64-bit): The classic Microsoft.Jet.OLEDB.4.0 provider is a 32-bit component. If your Application Pool is running in 64-bit mode, this connection will fail.
    • Solution: Navigate to your website properties, edit the IIS Application pool settings, and enable 32-bit applications.
    • Alternatively, for newer Access files (.accdb), use the Microsoft.ACE.OLEDB.12.0 provider.
© Copyright 2025 Doka management panel