Public Sub loadpeople()
Dim sqlQuery As String = "SELECT tbl_people.ID, tbl_people.fname, tbl_people.lname, tbl_time.date, tbl_time.time, tbl_time.status FROM(tbl_people)INNER JOIN tbl_time ON tbl_people.id = tbl_time.id"
Dim sqlAdapter As New MySqlDataAdapter
Dim sqlCommand As New MySqlCommand
Dim TABLE As New DataTable
Dim i As Integer
With sqlCommand
.CommandText = sqlQuery
.Connection = sConnection
End With
With sqlAdapter
.SelectCommand = sqlCommand
.Fill(TABLE)
End With
'แก้ไขสำหรับหน้าข้อมูล
lvtime.Items.Clear()
For i = 0 To TABLE.Rows.Count - 1
With lvtime
.Items.Add(TABLE.Rows(i)("id")) 'ไอดี
With .Items(.Items.Count - 1).SubItems
.Add(TABLE.Rows(i)("date"))
.Add(TABLE.Rows(i)("time"))
.Add(TABLE.Rows(i)("fname"))
.Add(TABLE.Rows(i)("lname"))
.Add(TABLE.Rows(i)("status"))
End With
End With
Next
End Sub
Dim sqlQuery As String = "select * FROM tbl_time WHERE id like '%" & TextBox1.Text & "%' order by date ASC"
Dim sqlAdapter As New MySqlDataAdapter
Dim sqlCommand As New MySqlCommand
Dim sqltable As New DataTable
With sqlCommand
.CommandText = sqlQuery
.Connection = sConnection
End With
With sqlAdapter
.SelectCommand = sqlCommand
.Fill(sqltable)
End With
lvtime.Items.Clear()
For i = 0 To sqltable.Rows.Count - 1
With lvtime
.Items.Add(sqltable.Rows(i)("id")) 'ไอดี (รันอัตโนมัติ)
With .Items(.Items.Count - 1).SubItems
.Add(sqltable.Rows(i)("date"))
.Add(sqltable.Rows(i)("time"))
End With
End With
Next
If TextBox1.Text = "" Then
loadpeople()
End If