Humprey Evangelista Cogay

My Programming Adventures

Windows 7 64Bit Microsoft Access 2007 Problem [Solved] "architecture mismatch between the Driver and Application"

I just installed my PC with Windows 7 64bit, Microsoft Office 2007 and Visual Studio 2010. I was trying something and I have decided to use Microsoft Access as my database, After a few minutes I found my self scratching my head because I cannot Connect My App to my MS Access Database because of thess errors

         "The setup routines for the Microsoft Access Driver(*.mdb, *.accdb) ODBC driver could not be found. Please reinstall the driver"

          Errors Found: The specified DSN contains an architecture mismatch between the Driver and Application

 

Here are some screen shots

 

After googling around I found this 2007 Office System Driver: Data Connectivity Components  Just Download and install it.

and I also found this Windows 7 RC ODBC Access driver, So this lead me to C:\Windows\SysWow64. So what I did was to create a DSN File named MyAccessDatabase.dsn using the odbcad32.exe found inside C:\Windows\SysWow64 instead of the Data Sources (ODBC) Applet found under the Administrative Tools Control Panel Folder

Here's the resulting DNS File

      [ODBC]
     DRIVER=Microsoft Access Driver (*.mdb, *.accdb)
     UID=admin
     UserCommitSync=Yes
     Threads=3
     SafeTransactions=0
     PageTimeout=5
     MaxScanRows=8
     MaxBufferSize=2048
     FIL=MS Access
     DriverId=25
     DefaultDir=c:\Data
     DBQ=C:\Data\database.accdb

So this Works Perfectly now Cool

OdbcConnection cnn = new OdbcConnection();
            cnn.ConnectionString = @"filedsn=C:\Data\MyAccessDatabase.dsn;
                                                       Uid=admin;Pwd=password;"
;

            try
            {
                cnn.Open();
                MessageBox.Show(cnn.State.ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                cnn.Close();
            }

But if you dont use a File DSN this should Work Fine......

OleDbConnection cnn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;
Data Source=c:\database.accdb;Jet OLEDB:Database Password=password;"
);

 


cnn.open();

Posted: 11-28-2010 10:23 PM by Comgen | with no comments
Filed under: , , ,