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.