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

B

Brian

Thanks for the help again!

Went onto that link and corrected my connection string but don't think
Visual Studio liked the format of it.

I have the exact same connection string to fill up a ListBox elsewhere
and that works so i don't know why i'd need a different connection
string here.

Anyways.. here's my entire code (connection string at top - the
photoDB.mdb database is in the project's Debug folder)

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

// load categories
string strDSN = "Provider=Microsoft.Jet.OLEDB.4.0;DataSource=photoDB.MDB";
string strSQL = "SELECT * FROM categories" ;
OleDbConnection conn = new OleDbConnection(strDSN);
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

Hey Brian,

It is because the app cannot find the database. I can reproduce this error
exactly. If you replace your connection string with:

....new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=D:\MyJetTest.mdb"); // <- NOTE path to directory containing mdb goes
here...

....you should be fine. If you continue to have problems please reply to
this post.

Good Luck!
 

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