1
votes

I have a ASP.NET MVC application (64bits) running in a 64 bits Windows system (Windows Server 2012).

My web application needs to read a mdb database, then I created the next code:

using (var myConnection = new OdbcConnection())
{                    
    try
    {
        string myConnectionString = @"Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=" + fileNameWithPath + ";Persist Security Info=True";
        myConnection.ConnectionString = myConnectionString;
        myConnection.Open();

        OdbcCommand cmd = myConnection.CreateCommand();
        cmd.CommandText = "SELECT * FROM myTable";
        OdbcDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);

        // Load the result into a DataTable
        myDataTable = new DataTable();
        myDataTable.Load(reader);
    }
    catch (Exception exception)
    {
        //nexy exception is caught here: "ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified"
    }
    finally
    {
        myConnection.Close();
    }
}

Where fileNameWithPath is the path of the mdb file.

When I execute the code above, I have the next annoying exception in the line

myConnection.Open();:

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

I've checked the server and it has the next files installed regarding ODBC driver:

File odbcad32.exe under the folder C:\Windows\System32

File odbcad32.exe under the folder C:\Windows\SysWOW64

My question is: Is my server setup correct? Do I have the 64 bits version of ODBC really installed?

and more important: Can I run a x64 application in x64 server with such configuration? Otherwise, is there any other alternative? It is worth to mention that:

  • I'm not allowed to install additional software in the server
  • The web application must be 64 bits

Thanks in advance.

2

2 Answers

2
votes

To use the x32 bit version of the Access database engine, then you will require an x32 bit version of the database engine installed on that computer.

And to use the x64 bit version of the Access database engine, then you require an x64 bit version of the Access database engine to be installed.

And hey, if you need to read an oracle database, then lo and behold, you need the oracle database engine installed to read oracle files that reside on the disk drive.

If you can’t install any additional software such as oracle to read oracle files, or SQL server to read sql server files, or in this case Access, then you are duck soap. And really, to read PDF files, then you need some PDF file software installed.

So unless you can get around the issue of not being allowed to install the appropriate software on your server, then you not going to be able to read the given files that such software consumes – this applies to near EVERY software system - you need to install the appropriate software on that server to enable use of such files.

So there does exist both an x32 and x64 bit version of the Access database engine (ACE), and unless you are allowed to install such software then you can’t read and consume such data.

So keep in mind that when developing software, if you want to open a word file, or pdf file or like any software system you will require the apocopate software to be installed to work with such files – Access is no exception. If you need to open a power point file, then it becomes obvious that you need power point software installed on that computer.

So you need to obtain and install the x64 bit version of the Access database engine on that server. And since you note you can’t install any software, then you are unlikely to achieve your goal.

0
votes

I resolved a very similar issue by enabling 32-bit applications in the advance settings of the application pool in IIS