Share via


OleDB Connection does not work, no error in debug, code stops executing

Question

Friday, May 10, 2013 12:22 PM

Hey there,

since 2 days I'm confronted with an issue I just can't find any solution.

I use Visual 2012 Ultimate x86 and Office 2010 x86 on a Windows 7 x64 system. Project is set to x86 as well. I am trying to open an OleDBConnection in Visual C#. Code is fairly simple:

        private void Main_Load(object sender, EventArgs e)
        {
            using (OleDbConnection connection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;
     Data Source=C:\data.mdb")) // the connection string can be anything, doesnt matter whether wrong or right
            {
                connection.Open();
                // any code after once accessing the OleDBConnection object won't be executed
                MessageBox.Show("test");    // msgbox not showing
            }
        }

Now I ve been trying almost any solution you might find on the web already:

- Installed AccessDataBaseEngine both 2007 and 2010

- Reinstalled all products: VS, Office and the DBEngines

- checked reg keys

- run regsvr32 on the respective dll's

- and some points I might have forgotten

I simply can't find the problem's origin. 

Only one thing I ve noticed that might lead to something useful: If I go to Settings -> Datasources (ODBC) it opens the x64 admin interface. Selecting MS Access Database and trying to edit that one I get the "Setup Routines not installed" - error. However, Access is x86 so I couldn't install the database engine for x64 anyways. Could it still be connected to that in some way (maybe VS2012 chooses the wrong one by accident?)?

Please help me!

Kind regards,

ray187

All replies (3)

Friday, May 10, 2013 12:37 PM ✅Answered

Hi,

Have you checked the exception settings in VS to make sure no exception are ignored ? Is UAC enabled ? You are not allowed to write on the root of the c: drive and opening an Access file requires creating a .ldb file at the same location so my guess would be that you have an exception because of that but that it is ignored...

Start by checking http://msdn.microsoft.com/en-us/library/d14azbfh.aspx to make sure no exception is ignored.It will be easier to solve the issue once you have an exception that will tell what is exactly the error rather than having to go through all possible causes...

Please always mark whatever response solved your issue so that the thread is properly marked as "Answered".


Friday, May 10, 2013 4:21 PM ✅Answered

Hi,

Have you checked the exception settings in VS to make sure no exception are ignored ? Is UAC enabled ?

This one really saved my life. I would have never figured that exception settings all of the sudden change, in fact I've never touched them so far. Before installing AccessDatabaseEngine the already-known exception "Microsoft.Jet.OLEDB.14.0' provider is not registered on the local machine" came up. When I installed the DBEngine, there was no exception coming up anymore.

Now that I selected all exceptions, they re-appeared :). Again "Microsoft.Jet.OLEDB.14.0' provider is not registered on the local machine" comes up. The solution for me is now to change "Jet" to "ACE" and version to 12.0 so the correct conn string would be "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=...".

However I would have never figured that seeing no exception got thrown in the first place. 

Thanks a lot to both who replied, I would have stuck at this one for quite some time and on top I now got to know the exception settings :).

Kind regards!


Friday, May 10, 2013 2:10 PM

You said you're running on a Windows 7 x64 system. I think, Microsoft.Jet.OleDB.4.0 is only available in 32-bit. Please, refer to this post on stackoverflow: http://stackoverflow.com/questions/1991643/microsoft-jet-oledb-4-0-provider-is-not-registered-on-the-local-machine

Kind regards,

wizend