OleDbDataAdapter Update Question

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
 
G

Guest

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

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