0

Can not connect MSAcess through ODBC. OdbcConnection.Open thrown an exception like

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

code portion is follows:

 string connetionString = null;
            OdbcConnection cnn;
            connetionString = (@"Driver={Microsoft Access Driver (*.mdb,*.accdb)};Dbq=E:\aa.mdb;Exclusive=1;Uid=Admin;Pwd=;");
 cnn = new OdbcConnection(connetionString);
            try
            {
                cnn.Open();
                MessageBox.Show("Connection Open ! ");
                cnn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Can not open connection ! ");
            }
step
  • 2,254
  • 2
  • 23
  • 45
MAnoop
  • 31
  • 1
  • 6
  • 1
    possible duplicate of [Is there a Windows 7 ODBC driver for Access?](http://stackoverflow.com/questions/2013837/is-there-a-windows-7-odbc-driver-for-access), [Windows 7 64 bit odbc drivers for Ms Access Missing](http://stackoverflow.com/questions/6721702/windows-7-64-bit-odbc-drivers-for-ms-access-missing), and several others. Please use the search box at the top right of any page. – Cody Gray - on strike Aug 09 '12 at 07:00
  • Please pay attntion to your speelling. Wrong spelling makes people trigger-happy. – Gert Arnold Aug 10 '12 at 12:42

1 Answers1

1

Your connection string is wrong, this works for me:

connetionString = (@"Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=E:\aa.mdb;Uid=Admin;Pwd=;");

See http://connectionstrings.com

Fionnuala
  • 90,370
  • 7
  • 114
  • 152