Transaction and RowState problem

  • Thread starter Thread starter perspolis
  • Start date Start date
P

perspolis

Hi all
I have a master detail table which I use them in Transaction to Update them.
in some cases the detail table generates error and I Rollback transaction
but RowState of master table dosen't go back to previous state and no data
has entered in database yet but in my master table in memory it has data..
????
how can I change RowState of master table to previous RowState before
begining Save.

thanks in advance
 
I want to keep the data that user has entered..
In master table after inserting I return the Identity column.
If I set the UpdatedRowSource InsertCommand to UpdateRowSource.None it
keeps the RowState but dosen't update Identoty column.
 
Hi,

In the 2.0 framework you can just call the SetAdded() method on the master
DataRow to return its RowState back to Added, if an error occurs.

In earlier versions of the framework you'll have to remove the row and then
add it back again, AFAIK. In that case check out the DataTable.LoadDataRow()
method and DataRow.ItemArray property.

In either case, setting UpdatedRowSource to None isn't really necessary,
unless you have referenced the AutoNumber value somewhere else and it needs to
be preserved. Instead, you can explicitly set the detail row's foreign key to
the new value of the primary key in the master record (returned by the
database) after resetting the master RowState to Added.
 
Back
Top