OLE DB provider not registered on one app but not another. RRS feed

  • Question

  • I have an odd situation I could use some assistance with.


    I wrote a simple console application to just test and work with different OLE DB connection strings and verify I have them right before I move them to my larger application.

    Here is my console app.

    static void Main(string[] args)
                string conString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\temp\\oledb.accdb;Persist Security Info=False";
                OleDbConnection con = new OleDbConnection (conString);
                try {
                    Console.WriteLine("Connection Made");
                    OleDbCommand com = new OleDbCommand("Select count(*) from testdb", con);
                    OleDbDataReader reader = com.ExecuteReader();
                    reader.Read(); //get to first line
                    Console.WriteLine(string.Format("{0} rows found in testdb", reader.GetInt32(0)));
                }//try to open connection
                catch (Exception ex)
                    Console.WriteLine (ex.ToString());

    simply enough and it works fine.  Gets the row count perfectly.


    No I have a much larger application where I literally copied the connection string over and I am getting the following error on connecting.

    +        $exception    {"The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine."}    System.Exception {System.InvalidOperationException}

    I really don't understand how I can run error free on the console app but with the Windows form app it blows up.


    The code for the big app is just as simple.  The only difference is the code is executed within a thread.  Could that impact it?

    Here is the class method that opens the connection and throwing the error.

    public bool connect()
                    con = new OleDbConnection(connectionString);
                    if (con.State != ConnectionState.Broken ||
                        con.State != ConnectionState.Closed)
                        return true;
                        return false;
                }//try to connect
                catch (Exception)
                    return false;
            }//connect to Database

    Any ideas??


    Tuesday, November 15, 2011 8:07 PM

All replies

  • Figured it out.. the console app is x86.  The larger app is 64bit.

    Tuesday, November 15, 2011 8:11 PM