H
Hardin
I have a typed dataset with 3 datatables from Northwind: Customers, Orders,
and Order Details with the appropriate relations and cascade updates and
deletes set in the dataset.
I have a SQLDataAdapter for each table, with Wizard-generated stored
procedures used for Select, Update, Insert, and Delete.
At update time, I use GetChanges to get a new dataset, return that dataset
to a middle-layer, and run the following code (the dataset of just changed
data is called "ds" based on code in David Sceppa's book:
//Update order: Deletes, Updates, Inserts
try
{
// Deletes go from bottom up
daDetails.Update(ds.Tables["Order Details"].Select("", "",
DataViewRowState.Deleted));
daOrders.Update(ds.Tables["Orders"].Select("", "",
DataViewRowState.Deleted));
daCust.Update(ds.Tables["Customers"].Select("", "",
DataViewRowState.Deleted));
// Updates go from top down
daCust.Update(ds.Tables["Customers"].Select("", "",
DataViewRowState.ModifiedCurrent));
daOrders.Update(ds.Tables["Orders"].Select("", "",
DataViewRowState.ModifiedCurrent));
daDetails.Update(ds.Tables["Order Details"].Select("", "",
DataViewRowState.ModifiedCurrent));
//Inserts go from top down
daCust.Update(ds.Tables["Customers"].Select("", "",
DataViewRowState.Added));
daOrders.Update(ds.Tables["Orders"].Select("", "",
DataViewRowState.Added));
daDetails.Update(ds.Tables["Order Details"].Select("", "",
DataViewRowState.Added));
}
.....
First, there are no exceptions thrown during this process.
However, the update process appears to be incomplete, and it seems to be
caused by a problem with the DataAdapter.Update method. After one of the
statements above executes, the dataAdapter (according to MS's documentation)
calls AcceptChanges. If it called AcceptChanges just on each row as it was
sent to the SQL StoredProcedure, that would be fine. But instead, it seems
to either be calling it on the entire dataset or else AcceptChanges is
bubbling down the relations change in the dataset. In any case, if there
are changes or updates to more than one table, this routine only updates one
but marks all pending changes as unchanged.
Any suggestions, code samples, property settings, etc., that anyone can
suggest to make this work?
Thanks a lot,
-- Hardin
and Order Details with the appropriate relations and cascade updates and
deletes set in the dataset.
I have a SQLDataAdapter for each table, with Wizard-generated stored
procedures used for Select, Update, Insert, and Delete.
At update time, I use GetChanges to get a new dataset, return that dataset
to a middle-layer, and run the following code (the dataset of just changed
data is called "ds" based on code in David Sceppa's book:
//Update order: Deletes, Updates, Inserts
try
{
// Deletes go from bottom up
daDetails.Update(ds.Tables["Order Details"].Select("", "",
DataViewRowState.Deleted));
daOrders.Update(ds.Tables["Orders"].Select("", "",
DataViewRowState.Deleted));
daCust.Update(ds.Tables["Customers"].Select("", "",
DataViewRowState.Deleted));
// Updates go from top down
daCust.Update(ds.Tables["Customers"].Select("", "",
DataViewRowState.ModifiedCurrent));
daOrders.Update(ds.Tables["Orders"].Select("", "",
DataViewRowState.ModifiedCurrent));
daDetails.Update(ds.Tables["Order Details"].Select("", "",
DataViewRowState.ModifiedCurrent));
//Inserts go from top down
daCust.Update(ds.Tables["Customers"].Select("", "",
DataViewRowState.Added));
daOrders.Update(ds.Tables["Orders"].Select("", "",
DataViewRowState.Added));
daDetails.Update(ds.Tables["Order Details"].Select("", "",
DataViewRowState.Added));
}
.....
First, there are no exceptions thrown during this process.
However, the update process appears to be incomplete, and it seems to be
caused by a problem with the DataAdapter.Update method. After one of the
statements above executes, the dataAdapter (according to MS's documentation)
calls AcceptChanges. If it called AcceptChanges just on each row as it was
sent to the SQL StoredProcedure, that would be fine. But instead, it seems
to either be calling it on the entire dataset or else AcceptChanges is
bubbling down the relations change in the dataset. In any case, if there
are changes or updates to more than one table, this routine only updates one
but marks all pending changes as unchanged.
Any suggestions, code samples, property settings, etc., that anyone can
suggest to make this work?
Thanks a lot,
-- Hardin