Public Class Form1
Dim returntable As DataTable = New DataTable("returnTable")
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim sSearchtext As String = "HP"
Dim table As DataTable = New DataTable("table")
Dim colItem As DataColumn = New DataColumn("col1", Type.GetType("System.String"))
table.Columns.Add(colItem)
Dim colItem1 As DataColumn = New DataColumn("col2", Type.GetType("System.String"))
table.Columns.Add(colItem1)
Dim NewRow As DataRow
NewRow = table.NewRow()
NewRow("col1") = "HP"
NewRow("col2") = "Dell"
table.Rows.Add(NewRow)
Dim NewRow2 As DataRow
NewRow2 = table.NewRow()
NewRow2("col1") = "ViewSonic"
NewRow2("col2") = "Generic"
table.Rows.Add(NewRow2)
table.AcceptChanges()
'clone the table schema
returntable = table.Clone
For Each row As DataRow In table.Rows
For Each col As DataColumn In table.Columns
'compare each column value
If String.Compare(row(col).ToString(), sSearchtext, True) = 0 Then
'if match then load value
LoadData(row)
'exit now no need to continue to search the rest of the columns
Exit For
End If
Next
Next
MsgBox(returntable.Rows.Count.ToString)
End Sub
Private Sub LoadData(ByRef rRow As DataRow)
Try
'
returntable.ImportRow(rRow)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
End Class