Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO.NEt DataRow question

Status
Not open for further replies.

stemy

Programmer
Aug 25, 2001
39
IL
Hi
I'm using the method DataRow.GetParentRows, and I noticed it does not return rows that are marked with DataRowState.Deleted. Is there a way to make it return them ? Is there maybe another method I could use ?
Thanx
 
Deleted rows to not have a DataViewVersion.Current state, and I think that is why you can't see them.

Look at the DataRowVersion.Original state to see deleted data. Note that if AcceptChanges has been called on the datatable, the deleted row is no longer accessible.
 
I tried using all the RowStateVersions but non of them showed me deleted rows :(
 

My mistake - misread your original post (sorry!)

I'm a bit confused here, or more likely am missing the point.

Surely if you delete a parent row then the child rows are also deleted due to the DataRelation constraint ? In that case, you would not be able to call the GetParentRows on a child row whose parent has been deleted, as the child row has also been deleted. If the createConstraints property of the DataRelation has been set to False then the child rows would still exist but calling GetParentRows would not return any rows because the parent row was deleted.

Can you post some code to demonstrate what you are trying to achieve ?

 
Stemy,

oDataView = New DataView(oDataSet.Tables(0))
oDataView.RowStateFilter = DataViewRowState.Deleted

Try this code, I am guessing that you just want to get all the deleted rows from a dataset. If that is the case this will work.

Kris
 
Actually, I'm using GetChildRows. Here's some code:
Code:
Dim row as DataRow
Dim rows() as DataRow
...
...
rows = row.GetChildRows()
[code]

I want GetChildRows to also return rows that are marked deleted. The reason, is that I want to know if I need to update the child table in the datasource.
 
Kris11 has the correct code - neither GetChildRows or GetParentRows will expose deleted rows.

If you are looking for all deleted child rows for a particular parent record, add the following to Kris11's code:

oDataView. = "ParentID = 1"

where 'ParentID' is the related column in the child table and '1' is the parent record ID (or whatever the key is).

You can then iterate through the DataView and use the DataRowVersion to see the Original data in the deleted rows.
 
Oops, sorry!

Should have typed:

oDataView.RowFilter = "ParentID = 1"

Doh!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top