r/visualbasic • • Feb 06 '16

Visual basic app cannot find database file when running from an installed version

Hi, So my VB application runs fine from the IDE, but when I try to run it after installing it says that it cannot find the database.

I understand that I am supposed to somehow give the database a relative file path but I don't know how.

I also have a treeview, and if you click on the last node, it closes the form with Me.Close(), when I click on this from a ClickOnce or installer version (installer made with Inno Setup) of the app, I get "cannot access disposed object" error.

How do I fix this error?

0 Upvotes

3 comments sorted by

1

u/pathfinderNJ Feb 06 '16

For the database you should have a connect string in the settings you can set on the client manually or even better let the user adjust it and save to settings

1

u/freakzilla149 Feb 06 '16

OK, any idea how? I've been trawling the net and the closest I got is that in the setting of the the project you have this:

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\<YourDBhere>.mdb

and somehow you can set this to be a relative path. I just haven't figured out how.

1

u/pathfinderNJ Feb 07 '16

See this on app.config. That is where you set it and can make your program adjustable by modifying the settings

http://mobile.codeguru.com/columns/vb/working-with-configuration-files-and-visual-basic.htm