Unexpected error with Database connection in VB.Net

I have a VB.Net program that is the front end for a Access databse. I am now trying to deploy the program
and so have moved the database into the same folder as the project so that it can find the database. However when I
changed the connection settings to simply "Database.mdb" and ran the program I got the following error message:

An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll

What am I doing wrong?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


Firstly, your connection string shoud still say "Provider=...." and you have simply removed the path within the Data Source setting.

Next, maybe just terminology, but you have made sure the .EXE (or .DLL) is in the same folder as the database rather than the project (.proj)

You are running this on a client operating system with the .Net framework / MDAC installed ?


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cookie_CrumAuthor Commented:
Not 100% sure I've read you correctly but I checked the connection in the server explorer and it still reads "Provider =..." the only thing I changed
was the settings within OleDbDataAdapter. By ran the project I don't mean when the project was installed but when I ran the project within Visual Studio
(by pressing F5).

The machine I was running the program on had the .Net framwork installed, not sure what MDAC is!
Carl TawnSystems and Integration DeveloperCommented:
If you don't specify the full path to the DB then it is assumed to be in the build folder. If running under the debugger, as you are, the DB will need to be in the "YourProject\Bin\Debug" folder rather than the project folder.
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

carl is right and that's what I was trying to get to... i.e. the current running directory is probably not what you think it is
Bob LearnedCommented:
If you need a more explicit exception message, wrap the code in a Try...Catch and read the exception stack:


Catch ex As Exception


End Try

Cookie_CrumAuthor Commented:
Thanks!! fixed that problem nicely, just one more thing quickly, when the program is compiled during the creation of the setup file will
it recognise the database will in the Bin folder and compile that aswell? Or does it have to be in the main folder?
It won't automatically include the database within the setup project. You need to add this as a file and will therefore give it a path to pull in from when the setup project is compiled.
Cookie_CrumAuthor Commented:
So it will be enough to just include the file within the application folder?
Yes, you can add the file from the application folder to the setup project, then make sure that the EXE and MDB files will both be installed in the same destination library then you should be okay
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.