wrong path "|DataDirectory|\db.accdb" System.Data.OleDb.OleDbException was unhandled

Tenzen

Member
Joined
Aug 18, 2010
Messages
16
Programming Experience
3-5
wrong path "|DataDirectory|\db.accdb" System.Data.OleDb.OleDbException was unhandled

In new project like WindowsApplication there is no problem with adding DataGridView and then adding Access datebase to it.

But in my plugin I cannot do that. I had to add manualy line to Load event for filling table:
VB.NET:
Me.KwerendaTableAdapter.Fill(Me.DmwbdDataSet.Kwerenda)

But it cannot locate may database file (*.accdb)
VB.NET:
System.Data.OleDb.OleDbException was unhandled
  ErrorCode=-2147467259
  Message=Could not find file 'C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\dmwbd.accdb'.
  Source=Microsoft Office Access Database Engine



Adding database generated files Settings.settings and app.config were I can find:
VB.NET:
"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\dmwbd.accdb"
How to fix that |DataDirectory|? Becouse it's returning wrong path to my database file.
But it seems to be the same code in new WindowsApplication project and there is no problem...
 
Link: Where do I configure the expansion of the |DataDirectory| macro?

I seme to recall a problem with DLLs and the way their settings are compiled/configured. As you can see from the trouble I had in the above post, In the end I just added some code to change the connection string setting at runtime - you can execute a search for the db in the dll, but be aware that attempting to find the path of the DLL by most means actually ends up returning the path of the EXE that loaded the DLL.. either put the resource alongside the app (if the DLL is in a plugins subfolder) or build some kind of recursive directory searching i, if youre starting from the EXE's path in your search

Modifying the connection string at runtime is often asked; a search of these boards should bring up some tips
 
Back
Top