'System.Data.OleDb.OleDbException' when creating a new DataSet..

B

Brian

Cheers for that.. seems to work but one problem!

I'm adding information on photos into a database. And this method is
to load categories into a ComboBox to choose how to categorise the
photo just added.

However, using the database in quotes like i do below.. it looks for
the database in the same folder as the location of the picture just
added.

I need it to load the database from the Debug folder of the project.

Any suggestions on how to implement this Debug folder into my
ConnectionString?

Thanks again for all the help!

Brian

--------------------------------------------

{
// load categories
string strSQL = "SELECT * FROM categories" ;
OleDbConnection conn = new
OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=photoDB.mdb");
OleDbDataAdapter da = new OleDbDataAdapter(strSQL,conn);
DataSet ds = new DataSet();
da.Fill(ds);

cboCategory.DataSource = ds.Tables[0];
cboCategory.DisplayMember = "category"; //name of field you want to
display
}
 
G

Guest

Brian,

I am not sure that I understand what you are asking but let me take a guess...

Your project is looking for the database in directory [x] and you want it
to find the database in the Debug directory of your project. If this is what
you are asking then you simply change the DataSource portion of the
connection string from …

…DataSource=photoDB.mdb

to the exact location of the database…

…DataSource=C:\<put the name of your directory here>\bin\Debug\photoDB.mdb

You basically make the data source string look just like the file path would
in explorer (e.g. C:\Development\MyApp\bin\Debug\MyAccessDb.mdb)

Hope this helps!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top