Private Sub search1()
conn = New SqlConnection("Data Source=192.168.1.160;Initial Catalog=servername;Persist Security Info=True;User ID=akasa;Password=")
conn.Open()
Dim sql As String = "SELECT * FROM cartoon"
Dim cmd As SqlCommand = New SqlCommand(sql, conn)
Dim dsr As SqlDataReader = cmd.ExecuteReader
dsr.Read()
'ListView1.Columns.Add("ลำดับ", 10, HorizontalAlignment.Center)
'ListView1.Columns.Add("อ้างอิงจาก", 80)
'ListView1.Columns.Add("วันที่รับเข้า", 80)
'ListView1.Columns.Add("ชื่อการ์ตูน", 80)
'ListView1.Columns.Add("หมายเหตุ", 200)
dt = New DataTable
dt.Load(dsr)
Dim row As DataRow
ListView1.Items.Clear()
For Each row In dt.Rows
Dim li As New ListViewItem
li.Text = CType(row("cartid"), String)
li.SubItems.Add(CType(row("cartfrom"), String))
li.SubItems.Add(CType(row("cartdat"), Date))
li.SubItems.Add(CType(row("cartname"), String))
li.SubItems.Add(CType(row("cartdetail"), String))
ListView1.Items.Add(li)
li = Nothing
Next
dsr.Close()
End Sub