B
Billy Cormic
Hello,
I have two datatables A, and B. I am trying to add a row from
table A to table B. So far I have been unsuccessful. Every time I
add a row to table B it replaces the first row in table B rather than
adding an additional row. Can anyone help?
Thanks again,
Billy
'Globals
Dim test123 As New DataTable
Dim test456 As New DataTable
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button2.Click
Dim SelectedRowNumber As Integer =
dg_SearchParamOptions.CurrentCell.RowNumber()
Dim SelectedDataRow As DataRow =
test123.Rows(SelectedRowNumber)
Dim CopyOfSelectedDataRow As DataRow
test456 = test123.Clone
'test123.Rows(SelectedRowNumber).Delete()
Try
'test456.ImportRow(SelectedDataRow)
' test456.Rows.InsertAt(SelectedDataRow, LastRow)
' test456.LoadDataRow(SelectedDataRow.ItemArray)
' test456.Rows.Add
' CopyOfSelectedDataRow = test456.NewRow
Dim newRow As DataRow = test456.NewRow()
newRow.ItemArray = SelectedDataRow.ItemArray
Dim LastRow As Integer = test456.Rows.Count
test456.Rows.InsertAt(newRow, test456.Rows.Count)
'test456.Rows.Add(newRow)
test456.AcceptChanges()
DataGrid1.DataSource() = test456
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
I have two datatables A, and B. I am trying to add a row from
table A to table B. So far I have been unsuccessful. Every time I
add a row to table B it replaces the first row in table B rather than
adding an additional row. Can anyone help?
Thanks again,
Billy
'Globals
Dim test123 As New DataTable
Dim test456 As New DataTable
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button2.Click
Dim SelectedRowNumber As Integer =
dg_SearchParamOptions.CurrentCell.RowNumber()
Dim SelectedDataRow As DataRow =
test123.Rows(SelectedRowNumber)
Dim CopyOfSelectedDataRow As DataRow
test456 = test123.Clone
'test123.Rows(SelectedRowNumber).Delete()
Try
'test456.ImportRow(SelectedDataRow)
' test456.Rows.InsertAt(SelectedDataRow, LastRow)
' test456.LoadDataRow(SelectedDataRow.ItemArray)
' test456.Rows.Add
' CopyOfSelectedDataRow = test456.NewRow
Dim newRow As DataRow = test456.NewRow()
newRow.ItemArray = SelectedDataRow.ItemArray
Dim LastRow As Integer = test456.Rows.Count
test456.Rows.InsertAt(newRow, test456.Rows.Count)
'test456.Rows.Add(newRow)
test456.AcceptChanges()
DataGrid1.DataSource() = test456
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub