Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DataTable.GetChanges() is it possible to get rows by reference?

Dim dtModifiedData As DataTable = dtMain.GetChanges(DataRowState.Modified)

As the definition of the function says, it does copy the rows after filtering it from the main table.

Is it possible to get them by reference?

like image 222
Francesco Bonizzi Avatar asked Sep 07 '26 07:09

Francesco Bonizzi


1 Answers

Yes:

Dim modifiedRows = From row In dtMain.AsEnumerable()
                   Where row.RowState = DataRowState.Modified

If you need it in a DataTable, that's not possible because a DataRow always belongs to one DataTable. If you try to move it from one to another you'll get an exception. You need a method like ImportRow which creates a new DataRow with the values from the source-row. For the same reason CopyToDataTable on above LINQ query will also create new DataRows.

like image 102
Tim Schmelter Avatar answered Sep 12 '26 15:09

Tim Schmelter



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!