How to access deleted row information?

Cricket

Active member
Joined
Jan 6, 2005
Messages
28
Location
Hamilton, ON, Canada
Programming Experience
5-10
I'm trying to loop through deleted rows in a DataTable but it gives me the following error "Deleted row information cannot be accessed through the row."

How do you read the information from a row if it's RowState has been changed to Deleted?

Here is the code.

VB.NET:
 [size=2]
[/size][size=2][color=#0000ff]Dim[/color][/size][size=2] dt [/size][size=2][color=#0000ff]As[/color][/size][size=2] System.Data.DataTable = [/size][size=2][color=#0000ff]Me[/color][/size][size=2].dtSeriesStandardFeature.GetChanges()

[/size][size=2][color=#0000ff]For[/color][/size][size=2] x [/size][size=2][color=#0000ff]As[/color][/size][size=2] [/size][size=2][color=#0000ff]Integer[/color][/size][size=2] = 0 [/size][size=2][color=#0000ff]To[/color][/size][size=2] dt.Rows.Count - 1 [/size][size=2][color=#0000ff]Step[/color][/size][size=2] 1

MsgBox(dt.Rows(x).Item("fuid_Series"))

[/size][size=2][color=#0000ff]Next

[/color][/size]
 
Hi Cricket,

This will help u .................................
VB.NET:
[color=#0000ff]Dim[/color][size=2] dt [/size][size=2][color=#0000ff]As[/color][/size][size=2] System.Data.DataTable = [/size][size=2][color=#0000ff]Me[/color][/size][size=2].dtSeriesStandardFeature.GetChanges()

[/size][size=2][color=#0000ff]If[/color][/size][size=2] dt.Rows(x).RowState = DataRowState.Deleted [/size][size=2][color=#0000ff]Then

[/color][/size][size=2]           MsgBox(dt.Rows(x).Item("fname", DataRowVersion.Original))
[/size][size=2][color=#0000ff]Else[/color][/size]
[size=2]             MsgBox(dt.Rows(x).Item("fname"))[/size]
[size=2][color=#0000ff]End[/color][/size][size=2] [/size][size=2][color=#0000ff]If[/color][/size]
[size=2][color=#0000ff][/color][/size] 
[size=2][color=#0000ff]Regards,[/color][/size]
[size=2][color=#0000ff]Ritesh
[/color][/size]
 
I moved it to the ADO.NET forum. Your question is database related, more specifically ADO.NET functionality.

Thank you for posting in the most specific forum in your future posts.
 
lol@neal


here's another tip. this line of code:


VB.NET:
Dim dt As System.Data.DataTable = Me.dtSeriesStandardFeature.GetChanges()
 
 
 
well, getchanges can take a parameter:
 
'get all deleted rows
Dim dt As System.Data.DataTable = Me.dtSeriesStandardFeature.GetChanges(DataRowState.Deleted)

'get all deleted or modified rows
Dim dt As System.Data.DataTable = Me.dtSeriesStandardFeature.GetChanges(DataRowState.Deleted Or DataRowState.Modified)
 
Last edited by a moderator:
VB.NET:
Dim dt As System.Data.DataTable = Me.dtSeriesStandardFeature.GetChanges(DataRowState.Deleted)
In msdn ... it is sample of code to view deleted rows bt i tried this before.. i haven't got any successful result yet from this line of code....

can any say .. how it will work
 
I used this:

VB.NET:
DeleteTable = TableToCheck.GetChanges(DataRowState.Deleted)
and it worked for me, just make sure you are not calling

VB.NET:
DataTable.AcceptChanges()
before you check for deleted rows.
 
Back
Top