nCountM = 0
.....
' processing takes place here which selects the data to be inserted in the output datatable
.....
nCountM = nCountM +1
MultiTableDataSet.Tables("Out").NewRow()
MultiTableDataSet.Tables("Out").Rows.Add(New Object())
MultiTableDataSet.Tables("Out").AcceptChanges()
' Set first field of new row
' ---------------------------------
MultiTableDataSet.Tables("Out").Rows(nCountM).Item(0) = MultiTableDataSet.Tables("In1").Rows(nCount).Item("Field0")
nCountM = 0
.....
nCountM = nCountM +1
Dim newrow = MultiTableDataSet.Tables("Out").NewRow()
' Set first field of new row
newrow(0) = MultiTableDataSet.Tables("In1").Rows(nCount).Item("Field0")
' Add the row to the table
MultiTableDataSet.Tables("Out").Rows.Add(
And here using the second way:
nCountM = 0
.....
MultiTableDataSet.Tables("Out").Rows.Add(MultiTableDataSet.Tables("In1").Rows(nCount).Item("Field0"))
Dim ds = New DataSet1
Dim dt = ds.Tables.Add()
dt.Columns.Add("test1")
dt.Columns.Add("test2")
dt.Rows.Add("a", "b")
dt.Rows.Add("d", "b")
dt.Rows.Add("c", "b")
dt.Rows.Add("c", "a")
'This prints in DataTable order
' a, b
' d, b
' c, b
' c, a
For Each row In dt.DefaultView
Debug.Print(row("test1") & "," & row("test2"))
Next
'This sorts by test1 column
' a, b
' c, b
' c, a
' d, b
dt.DefaultView.Sort = "test1"
For Each row In dt.DefaultView
Debug.Print(row("test1") & "," & row("test2"))
Next
'This sorts by test1 and test2 columns
' a, b
' c, a
' c, b
' d, b
dt.DefaultView.Sort = "test1,test2"
For Each row In dt.DefaultView
Debug.Print(row("test1") & "," & row("test2"))
Next
If you are experiencing a similar issue, please ask a related question
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
16 Experts available now in Live!