Datarows are moved instead of copy
-
I wanted to have button through which user can copy the [order details] from one order id to anoth order id. For example order id: 10248 have 10 detail item and I wanted all these items to append in order id: 200. My problem is that below mentioned code is copying the detail items but it also removes the source detail record. Any clue! -------------------------------------------------------------------- Private Sub btnCopyOrderID_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCopyOrderID.Click Dim DataTable2 As DataTable = New DataTable DataTable2 = obj.GetDataSet.Tables(1).Clone ' ' copy required record into a new table: DataTable2 For Each MydataRow In obj.GetDataSet.Tables(1).Select("OrderID = " & xcopyOrderID.Text) DataTable2.ImportRow(MydataRow) Next MydataRow ' ' change order id in DataTable2 For i = 0 To DataTable2.Rows.Count - 1 DataTable2.Rows(i).Item("OrderID") = OrderID.Text Next ' 'paste records from DataTable2 to Original Table For Each NewdataRow In DataTable2.Rows obj.GetDataSet.Tables(1).ImportRow(NewdataRow) Next NewdataRow End Sub
-
I wanted to have button through which user can copy the [order details] from one order id to anoth order id. For example order id: 10248 have 10 detail item and I wanted all these items to append in order id: 200. My problem is that below mentioned code is copying the detail items but it also removes the source detail record. Any clue! -------------------------------------------------------------------- Private Sub btnCopyOrderID_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCopyOrderID.Click Dim DataTable2 As DataTable = New DataTable DataTable2 = obj.GetDataSet.Tables(1).Clone ' ' copy required record into a new table: DataTable2 For Each MydataRow In obj.GetDataSet.Tables(1).Select("OrderID = " & xcopyOrderID.Text) DataTable2.ImportRow(MydataRow) Next MydataRow ' ' change order id in DataTable2 For i = 0 To DataTable2.Rows.Count - 1 DataTable2.Rows(i).Item("OrderID") = OrderID.Text Next ' 'paste records from DataTable2 to Original Table For Each NewdataRow In DataTable2.Rows obj.GetDataSet.Tables(1).ImportRow(NewdataRow) Next NewdataRow End Sub
Hi there, When I have thrown nil-Exceptions with the MOF then any iteration requested is about empty data. Struct Real Nil -> repeated Dave