-- HEADER TABLE --
Private Sub Report_Load(sender As Object, e As EventArgs) Handles MyBase.Load
OpenDB() ' Connect db
ListView1.View = View.Details
ListView1.GridLines = True
ListView1.AutoSize = True
ListView1.FullRowSelect = True '' เลือกทั้งแถว ของ Listview
'' HEADER
ListView1.Columns.Add("PO", 100)
ListView1.Columns.Add("PRINT", 200)
ListView1.Columns.Add("CATON", 100)
ListView1.Columns.Add("QTY", 100)
ListView1.Columns.Add("P/L", 200)
ListView1.Columns.Add("LOC", 200)
ListView1.Columns.Add("CATON", 200)
ListView1.Columns.Add("QTY", 170)
'ListView1.SelectedIndex = 0
End Sub
--Add to list view--
Private Sub btnLOAD_Click(sender As Object, e As EventArgs) Handles btnLOAD.Click
ListView1.Items.Clear()
Dim sql2 As String
Dim rss2 As OleDbDataReader
sql2 = " select * from ............................................................."
rss2 = ExcuteReader(sql2)
Do While rss2.Read
AddListView(0) = rss2.Item("pono")
AddListView(1) = rss2.Item("cuspartno")
AddListView(2) = rss2.Item("ctn")
AddListView(3) = rss2.Item("orderqty")
AddListView(4) = rss2.Item("palletkey")
AddListView(5) = rss2.Item("shelve")
AddListView(6) = rss2.Item("ordctn")
AddListView(7) = rss2.Item("stkqty")
item = New ListViewItem(AddListView)
ListView1.Items.Add(item)
Loop
End Sub
-- Connect DB --
Sub OpenDB()
If dbCon.State = ConnectionState.Closed Then ' ถ้า Cloas ให้เปิด
Try
dbCon.Open()
MsgBox("สามารถติดต่อฐานข้อมูล")
Catch ex As Exception
MsgBox("ไม่สามารถติดต่อฐานข้อมูล")
End Try
End If
End Sub