ListView1.Items.Clear()
Dim TABLE As New DataTable
Dim i As Integer
Dim MySqlConnection As MySqlConnection
MySqlConnection = New MySqlConnection()
MySqlConnection.ConnectionString = "server=localhost;user id=root;password=1234; database =137"
MySqlConnection.Open()
Dim myadapter As New MySqlDataAdapter
Dim sqlquery = "select *from Order_buy where or_no ='" & TextBox1.Text & "';"
Dim command As New MySqlCommand
With command
.Connection = MySqlConnection
.CommandText = sqlquery
End With
With myadapter
.SelectCommand = command
.Fill(TABLE)
End With
For i = 0 To TABLE.Rows.Count - 1
With ListView1
.Items.Add(TABLE.Rows(i)("spa_code"))
With .Items(.Items.Count - 1).SubItems
.Add(TABLE.Rows(i)("spa_name"))
.Add(TABLE.Rows(i)("spa_version"))
.Add(TABLE.Rows(i)("spa_price"))
.Add(TABLE.Rows(i)("or_quan"))
.Add(TABLE.Rows(i)("or_price"))
End With
End With
Next
ผมคิดว่า ความต้องการของคุณ ควรจะลงเอยด้วยดีโดยคำสั่ง Query (ไม่จำเป็นต้องเขียนโปรแกรม เช่น C#/VB/etc...) Select PO_Heading.*, Sum(PR_detail) As Total From PO_Heading