How to handle deleted rows?

  • Thread starter Thread starter Ray Martin
  • Start date Start date
R

Ray Martin

I have two tables in the dataset:
-Invoice header which contains invoice total (Parent table)
-Invoice line which contains line item details (Child table)

I am using a data adapter to update the actual database
There are appropriate table relations

Here is the problem: If I delete a row from the Invoice_line I want to
recalculate the invoice total. I use a loop to recalculate the total line
item cost using the code below:, but I get an error (Deleted row information
cannot be accessed through the row). How can I loop thru the active records
without getting this error? I have tried using GetChildRows("invoice_table",
DataRowVersion.Proposed), but I get the error (There is no Proposed data to
access.).

If I use DatasetAll.AcceptChanges right after doing the delete, I don't get
the error, but then the OledbDataAdapter.Update does not do the
update/delete.



Code:
invoice_total = 0

' if a line is deleted this fails with an error due to no version

For Each child In Parent.GetChildRows("invoice_table")

invoice_total = invoice_total + (child("qty") *
child("unit_cost"))

Next child

OleDbDataAdapter1.Update(DataSetAll1)

OleDbDataAdapter2.Update(DataSetAll1)
 
Hi Ray,

Not that I see it clear, but why is this not?

OleDbDataAdapter1.Update(DataSetAll1,"parentTable")
OleDbDataAdapter2.Update(DataSetAll1,"childTable")

Cor
 
Back
Top