1

I am new to classic ASP. I would rather ask question than do hour of research to solve my problem.

I am accessing access database and getting the following error.

Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified    
/default1.asp, line 30

The culprit line is this

Set MyConn = Server.CreateObject("ADODB.Connection")
MdbFilePath = Server.MapPath("c:\database\MyDatabase.mdb") 
  1. Well, I do not have Access installed but I copied the .mdb file to the specified folder, will it work that way? I am familiar with SQL Server, and that has to run in order to retrieve data from it.

  2. It uses ADODB but I can't file the DLL. Can someone specify the DLL for me. What I have to do to get it working. Just registering it will work using regsvr32 my.dll?

  3. I could not find a connection string (I usually use a connection string to connect to my SQL Server). Do I need one for Access database in this case?

Please help

Nicholas Murray
  • 13,305
  • 14
  • 65
  • 84
TheTechGuy
  • 16,560
  • 16
  • 115
  • 136

1 Answers1

2

It's been a few years for me, so this answer might be a little out of date. Also, since the Access db ends in .mdb, I'm assuming that it's a pre-2007 database.

Yes, just the file should work. Access does not need to run, it just needs to read the file. However, you may need certain components installed to talk to the Access database (used to be MDAC - http://www.microsoft.com/download/en/details.aspx?id=1953, not 100% certain if it still is). MDAC contains the JET engine, which classic ASP uses to talk to Access files.

As for the connection string, this web site that provides some examples of access connection strings: http://connectionstrings.com/access

edit - adding more info

Just in case I'm not following the comments correctly, here's an example of how to connect to the Access database through Classic ASP:

Set MyConn = Server.CreateObject("ADODB.Connection")
MdbFilePath = "c:\database\MyDatabase.mdb" ''# Server.MapPath is not needed, since we are providing the whole path already
MyConn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & MdbFilePath

When running the code above, do you receive the error still? Also, what's the set up you're running (IIS7, IIS6, 32bit, 64bit)?

AnthonyWJones
  • 187,081
  • 35
  • 232
  • 306
Chris Young
  • 1,749
  • 12
  • 17
  • I also found [this msft link](http://support.microsoft.com/kb/306345). I added permission to the registry and also verified mdac is installed but still does not work. May be I am doing something wrong – TheTechGuy Mar 07 '12 at 05:00
  • ok that error disappear. I now am getting CreateObject failed – TheTechGuy Mar 07 '12 at 05:10
  • Is the CreateObject failed on the same line or elsewhere? Also, how are you opening the connection? Something like this might work if you're not already doing so: `MyConn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & MdbFilePath` – Chris Young Mar 07 '12 at 05:31
  • The actual culprit line is this `Set BACSE = Server.CreateObject("NAICSCodeSE2_1_0.Engine")`. I did register the DLLs. The install MDAC and now I am getting the above error again. There is not db connection in the application. – TheTechGuy Mar 07 '12 at 05:35
  • 1
    If you're running on a 64 bit server and you are using 32-bit objects, you will need to enable 32-bit mode for the application pool your site is running in. Read [this question](http://stackoverflow.com/questions/637326/how-to-guide-for-getting-a-classic-asp-application-working-under-iis-7-0) for more info. – Erik Oosterwaal Mar 07 '12 at 08:41