hello, im going to create POS project, can you help me how to retrieve all image from mysql db to listview, so that i can view all image that i save to my db, i already save image and use sreach button on retrieve image from db to picturebox. thank you guys .
the code below is not retrieving image from db to listview, but if you click listview it will retrieve image from db to picturebox
Dim constr As String = "Data Source = localhost; User ID = root; Database = chamchamber"
Dim cn As MySqlConnection
Dim cmd As MySqlCommand
Dim da As MySqlDataAdapter
Dim dt As DataTable
Dim ds As DataSet
Dim dr As MySqlDataReader
Private Sub ListView1_Click(sender As Object, e As EventArgs) Handles ListView1.Click
cn = New MySqlConnection(constr)
cn.Open()
cmd = New MySqlCommand
cmd.Connection = cn
cmd.CommandText = "SELECT * from category where id= '" & ListView1.SelectedItems(0).Text & "'"
dr = cmd.ExecuteReader()
If (dr.HasRows) Then
While (dr.Read())
With Me
'fetch image from database
Dim imgBytes() As Byte = dr("IMG") 'image field
Dim image As Bitmap = New Bitmap(New System.IO.MemoryStream(imgBytes)) 'convert binary to image
PictureBox1.Image = image 'show picture to picture box
End With
End While
Else
MsgBox("No records Found!")
End If
End Sub