TerryNewton
New member
- Joined
- Sep 13, 2006
- Messages
- 2
- Programming Experience
- Beginner
I have a somewhat related question. I founnd the posted answers very informative and resolved my immediate issue, but as I was already accessing the deleted rows in a different fashion lead to a question of what the 'Best' way of accessing the deleted rows is.
Recomended Code:
I used the following approach instead, directly pulling fro the base 'datatable':
The method recomended above (and in other places) accesses a 'datatable' construct specific for the deleted rows. The question is one of efficiency. What overhead is related to using the seperate 'datatable' construct? Is this table already in existance and are we only getting a reference to it, or is it built on demand at the time the 'getchanges' is called?
Recomended Code:
VB.NET:
[LEFT][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]e[/COLOR][/SIZE][SIZE=2].dtSeriesStandardFeature.GetChanges()[/SIZE]
[SIZE=2][COLOR=#0000ff][/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][SIZE=2] x [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/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 [/SIZE]
[SIZE=2] MsgBox(dt.Rows(x).Item("fuid_Series"))[/SIZE]
[SIZE=2][COLOR=#0000ff]Next[/COLOR][/SIZE][/LEFT]
I used the following approach instead, directly pulling fro the base 'datatable':
VB.NET:
Dim DR As DataRow
For Each DR In TargetTable.Rows
[INDENT]Select Case DR.RowState[INDENT]Case DataRowState.Deleted 'do delete[/INDENT][INDENT]DoDelete(DR)[/INDENT][INDENT]Case DataRowState.Added 'do add[/INDENT][INDENT]DoAdd(DR)[/INDENT][INDENT]Case DataRowState.Modified 'do update[/INDENT][INDENT]DoUpdate(DR)[/INDENT]End Select
[/INDENT]Next
The method recomended above (and in other places) accesses a 'datatable' construct specific for the deleted rows. The question is one of efficiency. What overhead is related to using the seperate 'datatable' construct? Is this table already in existance and are we only getting a reference to it, or is it built on demand at the time the 'getchanges' is called?
Last edited: