1

i'm trying to make a c# windows forms application with access database. Last night everything worked fine but this morning, when i run my application i get an error.

Error

With the text from details:

See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.Data.OleDb.OleDbException (0x80004005): Unspecified error: E_FAIL(0x80004005)
   at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection)
   at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
   at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionInternal.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
   at System.Data.OleDb.OleDbConnection.Open()
   at AplicatieElena.Form1.btnCauta_Click(Object sender, EventArgs e) in C:\Users\name\source\repos\AplicatieElena\AplicatieElena\Form1.cs:line 31
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.4390.0 built by: NET48REL1LAST_C
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll
----------------------------------------
AplicatieElena
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///C:/Users/name/source/repos/AplicatieElena/AplicatieElena/bin/Debug/AplicatieElena.exe
----------------------------------------
System.Windows.Forms
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.4390.0 built by: NET48REL1LAST_C
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.4360.0 built by: NET48REL1LAST_C
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.4390.0 built by: NET48REL1LAST_C
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Configuration
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.4190.0 built by: NET48REL1LAST_B
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Core
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.4390.0 built by: NET48REL1LAST_C
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
System.Xml
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.4084.0 built by: NET48REL1
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Data
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.4270.0 built by: NET48REL1LAST_C
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_64/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
System.Transactions
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.4084.0 built by: NET48REL1
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_64/System.Transactions/v4.0_4.0.0.0__b77a5c561934e089/System.Transactions.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.

After reading, i can tell there is a problem at line 31.

OleDbConnection conexiune = new OleDbConnection("Provider = Microsoft.ACE.OLEDB.12.0; Data Source = Trenuri.accdb");
conexiune.Open();

This is my line 30, respectively line 31.

I don't know what this error really means and if you can help me i would really appreciate. Thanks!

rene
  • 41,474
  • 78
  • 114
  • 152
  • Are you running on the same PC? Also - have you opened the Access DB exclusively in the Access app (which can cause this problem)? – Martin Jul 24 '21 at 08:13
  • From which folder did you run your app? Is that trenuri.accdb in that same folder? – rene Jul 24 '21 at 08:27
  • @rene yes, it's in the same folder. I've put the database in the `bin\x86\Debug` and it prompts the error above. I've also put the database in the `bin\Debug` folder and now i have another error: `External component has thrown an exception` – Marius-Marian Burlacu Jul 24 '21 at 08:34
  • Yeah, keep it in the x86 folder. You don't want to deal with 32-bits / 64-bits discrepancies as well. Let's keep it to one problem. – rene Jul 24 '21 at 08:41
  • You can open that Trenuri.acdb with MS Access on that location? – rene Jul 24 '21 at 08:43
  • yes, i can open it from the x86 folder UPDATE: when i go to the projects properties , in `build -> platform target`, `Prefer 32-bit` was disable. I enabled it, after running the app from visual studio, it said that it cannot find the Trenuri.accdb in `bin\Debug` (not `bin\x86\Debug`), i placed Trenuri.accdb in the folder and now it seems to be working like it should. I don't know if this is the right thing to do tho! – Marius-Marian Burlacu Jul 24 '21 at 08:48
  • for sake of testing: can you remove the spaces right in front and directly following the = and for your Data Source include the full path to that accdb, so make it: `Data Sourec=C:\Users\name\source\repos\AplicatieElena\AplicatieElena\bin\Debug\Trenuri.accdb` – rene Jul 24 '21 at 08:51
  • I reverted the changes and i did what you said but it s still the same error – Marius-Marian Burlacu Jul 24 '21 at 09:01
  • If you got it working with prefer 32 bits then you're good to go. Place the db where the error says it wants it to be. – rene Jul 24 '21 at 09:21

0 Answers0