?
Solved

Unexpected error with Database connection in VB.Net

Posted on 2006-04-06
9
Medium Priority
?
221 Views
Last Modified: 2010-04-23
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?

Thanks!
0
Comment
Question by:Cookie_Crum
9 Comments
 
LVL 6

Accepted Solution

by:
cubixSoftware earned 375 total points
ID: 16390519
Hi

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 ?

0
 

Author Comment

by:Cookie_Crum
ID: 16390621
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!
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 16390769
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.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 6

Expert Comment

by:cubixSoftware
ID: 16390913
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
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 16391352
If you need a more explicit exception message, wrap the code in a Try...Catch and read the exception stack:

Try

Catch ex As Exception

  MessageBox.Show(ex.ToString)

End Try

Bob
0
 

Author Comment

by:Cookie_Crum
ID: 16391672
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?
0
 
LVL 6

Expert Comment

by:cubixSoftware
ID: 16391794
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.
0
 

Author Comment

by:Cookie_Crum
ID: 16391919
So it will be enough to just include the file within the application folder?
0
 
LVL 6

Expert Comment

by:cubixSoftware
ID: 16398883
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
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question