Search code examples
windowsvb.netms-accessweb-applicationsadodb

Error Opening Connection to MS Access DB in VB.NET WEB APPLICATION when uploaded to server using ADO ODBC


I have a new application uploaded to Windows server that is attempting to read MS Access DB and I get the error:

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

Tracing shows that I get the error at the point where I try to open the connection.

This is my first WEB APPLICATION in Visual Studio 2019. I have other VS WEBSITE applications that also read DBs in the same way. Those work simply by referencing ADODB.DLL and then placing the ADODB.DLL file in the BIN folder of the published website.

I verified that the DB is good with all the proper permissions and connection strings by opening/reading the same database in my one of my website applications. No problem. Both my WEBSITE apps and my WEB APPLICATION read the database with the same exact class module attached to the project.

So the only difference appears to be that one is a WEB APPLICATION (with compiled code-behind) and the other is a WEBSITE (with uncompiled code behind). But again, the database is opened in an identical class modules attached to the projects.

I noticed that the PUBLISH feature in VS seems to ignore the ADODB.DLL file in my bin folder (ie does not publish it to the server even though it is referenced). But even if I manually upload the DLL to the BIN folder of the server, I get the error.

My server support says that I need to add a System.DSN to access the database. I tried that (may have done it incorrectly), but it didn't work. And seems wrong given that I read databases the same way in my website apps.

So it "feels like" the published web app DLLs cannot find the ADODB.DLL when it is accessed in a web application. Should I be putting it in a different location or publishing differently somehow?

Help?


Solution

  • Well, ok, so the site works local.

    There are two issues you have to deal with. First up, there is a good possible that the web site is running as x64 bits. As a result, that web site needs to have the x64 bit version of the Access database engine installed (ACE).

    In other words that target web site needs to have support for Access installed, and these days MOST web sites by default run as x64 bits

    And I believe that you need MORE then just the ADO .dll installed. If you use a mdb file, then the chances are rather high that JET x32 is installed. But if the web server is x64 bits, then you need to install x64 bit ACE on that server. This one:

    https://www.microsoft.com/en-us/download/details.aspx?id=54920

    Make sure from above that you choose the correct x64 bit one, or you may be able to force the web site to run as x32 bits - but that's often a issue.