From: rarahim on
Hi. I'm kinda new with ADO .NET. I'm having trouble saving edit and delete
changes back to the data source. Adding new record is fine. Only edits and
deletes don't work.

Here's my code:

Dim r As DataSet1.PeopleRow

OleDbDataAdapter1.Fill(DataSet11)

r = DataSet11.People.Rows(0)

r.Name = "Kevin"

r.AcceptChanges()

Dim ret As Integer = OleDbDataAdapter1.Update(DataSet11)

My DataAdapter and Dataset are strongly typed and they were created through
VS 2008 data wizard. By the way, I'm using an MS Access 2003 database with a
table called People.

People
Id : Number, primary key
Name: String

Please help as I'm really stuck. Thanks



--- news://freenews.netfront.net/ - complaints: news(a)netfront.net ---
From: Armin Zingler on
Am 23.04.2010 18:36, schrieb rarahim:
> Hi. I'm kinda new with ADO .NET. I'm having trouble saving edit and delete
> changes back to the data source. Adding new record is fine. Only edits and
> deletes don't work.
>
> Here's my code:
>
> Dim r As DataSet1.PeopleRow
>
> OleDbDataAdapter1.Fill(DataSet11)
>
> r = DataSet11.People.Rows(0)
>
> r.Name = "Kevin"
>
> r.AcceptChanges()
>
> Dim ret As Integer = OleDbDataAdapter1.Update(DataSet11)
>
> My DataAdapter and Dataset are strongly typed and they were created through
> VS 2008 data wizard. By the way, I'm using an MS Access 2003 database with a
> table called People.

Remove r.AcceptChanges(). The Update methods looks for records with row
state modified, added and deleted. If you call AcceptChanges before,
deleted records have been removed from the datatable, and the row state
of the remaining rows is unchanged. Consequently the update method
doesn#t find anything to do.

--
Armin