Topic: having trouble connecting to access database

I've never used ASP .NET 2.0 so I'm a total noob, but am looking to learn new things.

My problem is I'm getting the following error when trying to connect to a MS Access database -

Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

/test.asp, line 22

Here's my code:


Option Explicit

Dim objConn         ' Connection Name
Dim strConn   		' Connection String
Dim objRS           ' Recordset Variable
Dim strSQL          ' variable for SQL statement
Dim intTotalColumns
Dim intCounter

Const adOpenStatic  = 3
Const adLockReadOnly = 1

Set objConn = Server.CreateObject("ADODB.Connection")
Set objRS   = Server.CreateObject("ADODB.Recordset")

strConn = "DBQ=" & Server.MapPath("/db/tic.mdb")
strConn = "DRIVER={Microsoft Access Driver(*.mdb)};" & strConn
objConn.Open strConn

strSQL = "SELECT * FROM tickerposts"

objRS.Open strSql, objConn, adOpenStatic, adLockReadOnly


I'm using 1and1 as my host if that helps...



Daniel Marino |

Re: having trouble connecting to access database

Looks like you are using classic asp. I used to be with 1&1 a few years back.  I do know your database must be in the db folder which you have it in so that is good.

I would say check your slashes change / to \

I think this is what I used before, I have changed the db to tic.mdb


Set dbaseConn = Server.CreateObject("ADODB.Connection")
dbaseConn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.Mappath("\db\tic.mdb") & ";"
SQLQuery = "SELECT xxx"
Set RS = dbaseConn.Execute(SQLQuery)


For connection string help is a good place.

Hope that helps

† Taj

Re: having trouble connecting to access database

I found out the problem is that I was using a DSN (?) connection method, I tried using a non-DSN method and that works. I know they say that the database has to be in the db folder, but they lie! I had it in there at first and it was working, but I wanted to reorganize my directory structure, and it still works!

Daniel Marino |

Re: having trouble connecting to access database


If you are using 2.0, I would recommend using some of the built in classes such GridView or FormView to access and display data in pages.  This page from MSDN lists the basic steps to accessing  database in 2.0: … .71).aspx.  A basic example of executing a query in code and then accessing the result set can be found here: … ader.aspx.