error in system.data.oledb when compiling vb.net

uji

Member
Joined
Aug 23, 2006
Messages
7
Programming Experience
Beginner
I'm using Visual studio 2003. I have created a simple programming using VS 2003 with Microsoft Access 2000 as the database. I put the database in C:\learn vb.net\mydatabase\mydatabase\mydatabase.mdb.
In the app.config,
<?xmlversion="1.0"encoding="utf-8"?>
<configuration>
<appSettings>
<addkey="dsn"value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\..\mydatabase.mdb"/>
</appSettings>
</configuration>
I tried compiling it but it gives this error -
An unhandled exception of type 'System.Data.OleDB.OleDBException' occured in mydatabase.exe.

If anyone could point out to me the cause of the error, I really appreciate it. Thanks
 
Oh my goodness.. This is like saying to us:

"I clicked the play button and an error message came up. What do I do now?"



Please, help us out more.. post something meaningful, like an error message. An unhandled exception of type 'System.Data.OleDB.OleDBException' occured in mydatabase.exe is NOT an error message. Its a notification that an error occurred. We cant do anything with that..
 
I'm pretty sure that you cannot use relative paths like that in a connection string. If you don't know exactly what the path of the database will be at design time then you're going to have to create your connection string, or at least part of it, at run time.
 
Thanks for the feedbacks...I'm a beginner in VStudio 2003 programming..
The actual sample programming that I download from the internet is like below

<?xml version="1.0" encoding="utf-8" ?>
<
configuration>
<
appSettings>
<add key="dsn" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\PersonalManager.mdb" />
</appSettings>
</
configuration>

The database was in C:\learn vb.net\PersonalManager\PersonalManager.mdb

but since I put my database in C:\learn vb.net\mydatabase\mydatabase\mydatabase.exe, I modified the app.config
to addkey="dsn"value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\..\mydatabase.mdb"/>


Is this a correct way of putting it?
 
Is the database two levels up the directory tree relative to your executable? if not than that's not going to work. They would have used that path because the executable is in the 'bin' folder and the database is in the project folder. If you've done the same thing then the absolute path doesn't matter. The relative path will still be the same.
 
Given that your app and your database will likely live in the same directory in a production environment, you'd be well advised to set the database file copy attribute to "Copy If Newer", and have the connection string contain no path info at all
 
Back
Top