Updating Multi-Table Dataset

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I defined a dataset that contains two tables (parent-child)
I fill it with some data properly
Some changes happen, and I need to store it in DB

If I use "dataAdapter.Update (dataSet, firstTableName)", and then "dataSet.AcceptChanges()", will all the modified records state change (i mean in both tables in dataset)? or, just those from the first table

Thanks a lot
Mark
 
don't call update changes .. dataAdapter.Update do it for you when
committing changes to that specific row ..
if you do it yourself you won't have the chance to committ the changes to
the database.

do

dataAdapterParent.Update (dataSet, parentTableName)
dataAdapterChild.Update (dataSet, childTableName)

or use the code below if the 2 tables have a FK constraint activated on the
Database, if not you might get FK violations when you both add a new
parent-child set of rows and you remove another parent-child set of rows
into the same session:

dim rows() as datarows = ParentTable.select( .. get only rows in inserted
state)

dataAdapterParent.Update (rows) 'insert only new rows
dataAdapterChild.Update (dataSet, childTableName) 'insert, update , delete
child rows
dataAdapterParent.Update (dataSet, parentTableName) ' update , delete


HTH
Mark G said:
I defined a dataset that contains two tables (parent-child).
I fill it with some data properly.
Some changes happen, and I need to store it in DB.

If I use "dataAdapter.Update (dataSet, firstTableName)", and then
"dataSet.AcceptChanges()", will all the modified records state change (i
mean in both tables in dataset)? or, just those from the first table?
 
that's not exactly what i wanted to know..

may be, you know whether dataset.AcceptChanges() applies it only for given (updated) table or it's applied for all tables in a dataset, regardless appliance of dataadapter.Update()

Thanks
Mar

----- enrico sabbadin wrote: ----

don't call update changes .. dataAdapter.Update do it for you whe
committing changes to that specific row .
if you do it yourself you won't have the chance to committ the changes t
the database

d

dataAdapterParent.Update (dataSet, parentTableName
dataAdapterChild.Update (dataSet, childTableName

or use the code below if the 2 tables have a FK constraint activated on th
Database, if not you might get FK violations when you both add a ne
parent-child set of rows and you remove another parent-child set of row
into the same session

dim rows() as datarows = ParentTable.select( .. get only rows in inserte
state

dataAdapterParent.Update (rows) 'insert only new row
dataAdapterChild.Update (dataSet, childTableName) 'insert, update , delet
child row
dataAdapterParent.Update (dataSet, parentTableName) ' update , delet


HT
Mark G said:
I defined a dataset that contains two tables (parent-child)
I fill it with some data properly
Some changes happen, and I need to store it in DB
"dataSet.AcceptChanges()", will all the modified records state change (
mean in both tables in dataset)? or, just those from the first table
 
The dataadapter calls AcceptChanges for only the rows it has updated
Is this what you wanted to know ?

Mark G said:
that's not exactly what i wanted to know...

may be, you know whether dataset.AcceptChanges() applies it only for given
(updated) table or it's applied for all tables in a dataset, regardless
appliance of dataadapter.Update()?
 
Back
Top