Private Sub CompareRows(ByVal table1 As DataTable, ByVal table2 As DataTable)
For Each row1 As DataRow In table1.Rows
For Each row2 As DataRow In table2.Rows
If row1("Textiles_series_ID") = row2("TRD_LOT_NO") Then
Dim dt As New DataTable()
dt.Columns.AddRange(New DataColumn() {New DataColumn("ID", GetType(Integer)), _
New DataColumn("Textiles_series_ID", GetType(String)), _
New DataColumn("TRD_LOT_NO", GetType(String))})
Dim i As Integer = table1.Rows.Count
For j As Integer = 0 To i - 1
Dim dr As DataRow = dt.NewRow()
dr("ID") = j + 1
dr("Textiles_series_ID") = row1("Textiles_series_ID")
dr("TRD_LOT_NO") = row2("TRD_LOT_NO")
dt.Rows.Add(dr)
Next
GridView1.DataSource = dt
GridView1.DataBind()
Label1.Text = i
Else
'Console.WriteLine("Not Equal: {0} {1}", row1("Textiles_series_ID"), row2("TRD_LOT_NO"))
End If
Next
'Console.WriteLine("///////////////////////////////")
Next
'Console.ReadLine()
End Sub
2. เป็นส่วนในการเรียกข้อมูลที่อยู่ใน Data base มาเก็บและทำการแสดงใน Grid View
Code (VB.NET)
Private Sub ShowALLEmployees()
Dim SqlEmp As String
SqlEmp = " SELECT WO_ID,WO_Name,WO_Com,WO_Maxadd "
SqlEmp &= "FROM db_licensewinoffice order by WO_ID asc" ไปหามาก
If IsFind = True Then
Ds.Tables("db_licensewinoffice").Clear()
End If
DA = New MySqlDataAdapter(SqlEmp, Con_CallData)
DA.Fill(Ds, "db_licensewinoffice")
If Ds.Tables("db_licensewinoffice").Rows.Count <> 0 Then
IsFind = True
With DataGridView1
.ReadOnly = True
.DataSource = Ds.Tables("db_licensewinoffice")
End With
Else
IsFind = False
End If
FormatALLEmployees()
End Sub