Here is my code. It should be updating the first field in the first record
of the table. No errors occur when I run this but no data is updated either.
Any ideas?

Thanks.


System.Data.OleDb.OleDbConnection conn = new
System.Data.OleDb.OleDbConnection();
conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;" +
@"Password=pass;User ID=username;" +
@"Jet OLEDB:System database=q:\system.mdw;" +
@"Data source=q:\db.mdb";

conn.Open();

string query = "select * from table1";

OleDbDataAdapter da = new OleDbDataAdapter( query, conn );

DataSet ds = new DataSet();

da.Fill( ds );

ds.Tables[0].Rows[0].ItemArray[0] = "newvalue";

da.Update( ds );

Re: Trouble updating access database with dataset by chen

chen
Wed Jul 07 20:03:36 CDT 2004

you said "no data is updated"

did you check the dataset or the database file?

if you ONLY checked the dataset
{
append ds.AcceptChanges() after da.Update(ds);
run your application;
and check the dataset again;
}
else // you checked the database file, and no data was updated
{
check the da.UpdateCommand.Text;
}



"emde" <emde@na.com> wrote in message
news:uFs9F2HZEHA.3664@TK2MSFTNGP12.phx.gbl...
>
> Here is my code. It should be updating the first field in the first record
> of the table. No errors occur when I run this but no data is updated
either.
> Any ideas?
>
> Thanks.
>
>
> System.Data.OleDb.OleDbConnection conn = new
> System.Data.OleDb.OleDbConnection();
> conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;" +
> @"Password=pass;User ID=username;" +
> @"Jet OLEDB:System database=q:\system.mdw;" +
> @"Data source=q:\db.mdb";
>
> conn.Open();
>
> string query = "select * from table1";
>
> OleDbDataAdapter da = new OleDbDataAdapter( query, conn );
>
> DataSet ds = new DataSet();
>
> da.Fill( ds );
>
> ds.Tables[0].Rows[0].ItemArray[0] = "newvalue";
>
> da.Update( ds );
>
>
>
>
>
>
>
>
>


Re: Trouble updating access database with dataset by Samuel

Samuel
Wed Jul 07 20:23:39 CDT 2004

emde,

When you create the new data adapter, the select statement of the adapter is
automatically created for you.

To update the database you need to create the Insert, Update and Delete
commands of the data adapter.

The easiest way to do this is with the command builder object.

In VB I would add the following code after you declare the new data adpater:

<code (VB.NET) >
Dim dataCommandBuilder As New OleDb.OleDbCommandBuilder(da)
da.InsertCommand = dataCommandBuilder.GetInsertCommand
da.DeleteCommand = dataCommandBuilder.GetDeleteCommand
da.UpdateCommand = dataCommandBuilder.GetUpdateCommand
</code>

Then calling Update on the dataadapter should work.

I would also not use a full dataset, I would use a datatable instead. The
Dataset will contain many tables and relations and could cause an ambiguous
situation.



-Sam Matzen


"emde" <emde@na.com> wrote in message
news:uFs9F2HZEHA.3664@TK2MSFTNGP12.phx.gbl...
>
> Here is my code. It should be updating the first field in the first record
> of the table. No errors occur when I run this but no data is updated
either.
> Any ideas?
>
> Thanks.
>
>
> System.Data.OleDb.OleDbConnection conn = new
> System.Data.OleDb.OleDbConnection();
> conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;" +
> @"Password=pass;User ID=username;" +
> @"Jet OLEDB:System database=q:\system.mdw;" +
> @"Data source=q:\db.mdb";
>
> conn.Open();
>
> string query = "select * from table1";
>
> OleDbDataAdapter da = new OleDbDataAdapter( query, conn );
>
> DataSet ds = new DataSet();
>
> da.Fill( ds );
>
> ds.Tables[0].Rows[0].ItemArray[0] = "newvalue";
>
> da.Update( ds );
>
>
>
>
>
>
>
>
>



Re: Trouble updating access database with dataset by emde

emde
Wed Jul 07 23:16:04 CDT 2004


"Samuel L Matzen" <smatzen@slm.com> wrote in message
news:uLZN0oIZEHA.3476@tk2msftngp13.phx.gbl...
> emde,
>
> When you create the new data adapter, the select statement of the adapter
is
> automatically created for you.
>
> To update the database you need to create the Insert, Update and Delete
> commands of the data adapter.
>
> The easiest way to do this is with the command builder object.
>
> In VB I would add the following code after you declare the new data
adpater:
>
> <code (VB.NET) >
> Dim dataCommandBuilder As New OleDb.OleDbCommandBuilder(da)
> da.InsertCommand = dataCommandBuilder.GetInsertCommand
> da.DeleteCommand = dataCommandBuilder.GetDeleteCommand
> da.UpdateCommand = dataCommandBuilder.GetUpdateCommand
> </code>
>
> Then calling Update on the dataadapter should work.
>
> I would also not use a full dataset, I would use a datatable instead. The
> Dataset will contain many tables and relations and could cause an
ambiguous
> situation.
>
>
>
> -Sam Matzen


I am new to this and I am looking for something similar to a recordset that
is updateable. Maybe I should be looking into a datatable instead of a
dataset. I would like to loop through the data with the possibility of
updating a field.

Hmmm.