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

B

Brian

Hello.

Am getting an error message here at the line: DataSet dtSet = new DataSet();

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

Bizarre as i'm using the same code elsewhere (besides the name of a table)
to populate a listbox.

Can anyone suggest any reasons as to why i'm getting this error?

Thanks in advance.

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

string strDSN = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=photoDB.MDB";
string strSQL = "SELECT * FROM categories" ;

// create Objects of ADOConnection and ADOCommand
OleDbConnection myConn = new OleDbConnection(strDSN);
OleDbDataAdapter myCmd = new OleDbDataAdapter( strSQL, myConn );

myConn.Open();

DataSet dtSet = new DataSet();
myCmd.Fill( dtSet, "categories" );

DataTable dTable = dtSet.Tables[0];
foreach( DataRow dtRow in dTable.Rows )
{
cboCategory.Items.Add( dtRow["category"].ToString());
}

myConn.Close();
 

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