S
sevenso
I am having problems coding to an Access database (2000
format). I am using the Microsoft Development Enviroment
2003 and 1.1 .Net Framework.
Here is the code that I am trying:
string strConnect =
@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=D:\CSharp\Receipt\Test.MDB" ;
string strSQL = "SELECT * FROM Names";
try
{
OleDbDataAdapter adapter = new OleDbDataAdapter(strSQL,
strConnect);
DataSet ds = new DataSet("Names");
adapter.Fill(ds, "Names"); // never gets beyond here
string str = (string)ds.Tables["Names"].Rows[0]
["FirstName"];
DataRow newRow = ds.Tables["Names"].NewRow();
newRow["FirstName"] = "Teddy";
ds.Tables["Names"].Rows.Add(newRow);
ds.Tables["Names"].AcceptChanges();
}
catch (System.Data.OleDb.OleDbException ex)
{
MessageBox.Show(ex.Message);
Debug.WriteLine(ex.Message);
}
When this runs an exception is thrown at adapter.Fill
(...).
The message is: "IErrorInfo.GetDescription failed with
E_FAIL(0x80004005)."
I also can't open the database in the Data Connections
area of the IDE. I get an Unkown error message box.
Thanks for the help.
format). I am using the Microsoft Development Enviroment
2003 and 1.1 .Net Framework.
Here is the code that I am trying:
string strConnect =
@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=D:\CSharp\Receipt\Test.MDB" ;
string strSQL = "SELECT * FROM Names";
try
{
OleDbDataAdapter adapter = new OleDbDataAdapter(strSQL,
strConnect);
DataSet ds = new DataSet("Names");
adapter.Fill(ds, "Names"); // never gets beyond here
string str = (string)ds.Tables["Names"].Rows[0]
["FirstName"];
DataRow newRow = ds.Tables["Names"].NewRow();
newRow["FirstName"] = "Teddy";
ds.Tables["Names"].Rows.Add(newRow);
ds.Tables["Names"].AcceptChanges();
}
catch (System.Data.OleDb.OleDbException ex)
{
MessageBox.Show(ex.Message);
Debug.WriteLine(ex.Message);
}
When this runs an exception is thrown at adapter.Fill
(...).
The message is: "IErrorInfo.GetDescription failed with
E_FAIL(0x80004005)."
I also can't open the database in the Data Connections
area of the IDE. I get an Unkown error message box.
Thanks for the help.