OleDbDataAdapter Update Question

  • Thread starter Thread starter bob
  • Start date Start date
B

bob

Hi.. I'm making a OleDb connection to a access database.. I can fill
the dataset
fine and view the data, but when I add a new row and try to update the
db I get this error. Any help would be appreciated..

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

This error is from the following line:

thisAdapter.Update(thisDataSet, "tCompany");

Here's the code i'm using...
--------------------------------------------------------------------------------


OleDbConnection thisConnection = new
OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\devel\csharp\company\db\company.mdb");

OleDbDataAdapter thisAdapter = new OleDbDataAdapter("SELECT * FROM
tCompany", thisConnection);



DataSet thisDataSet = new DataSet();

thisAdapter.Fill(thisDataSet, "tCompany");

DataRow thisRow=thisDataSet.Tables["tCompany"].NewRow();
thisRow["name"]="some name";
thisRow["street"]="some street";
thisRow["city"]="some city";
thisRow["state"]="some state";


thisDataSet.Tables["tCompany"].Rows.Add(thisRow);

OleDbCommandBuilder thisBuilder = new
OleDbCommandBuilder(thisAdapter);
thisAdapter.Update(thisDataSet, "tCompany");



Thanks,

John Underwood
 
Either the connection is closed. Or an error occured during opening the connection. Try opening the connection to verify that first
 
Back
Top