Private Sub RETRIEVE()
ListView1.Clear()
Dim imglist As New ImageList
imglist.ColorDepth = ColorDepth.Depth32Bit
ListView1.LargeImageList = imglist
ListView1.LargeImageList.ImageSize = New System.Drawing.Size(50, 50)
Dim connection As New SqlConnection("Data Source=(local);Initial Catalog=images;Integrated Security=True")
Dim userdataadpter As New SqlDataAdapter("SELECT * FROM tbl_img ", connection)
Dim userdataset As New DataSet
Dim dt_images As New DataTable
userdataadpter.Fill(userdataset, "tbl_img")
For Each dr As DataRow In dt_images.Rows
Dim img_buffer = CType(dr("image"), Byte())
Dim img_stream As New MemoryStream(img_buffer, True)
img_stream.Write(img_buffer, 0, img_stream.Length)
imglist.Images.Add(dr("image").ToString(), New Bitmap(img_stream))
img_stream.Close()
Dim lsvpaarent As New ListViewItem
lsvpaarent.Text = dr("image").ToString
lsvpaarent.ImageKey = dr("imageID").ToString
ListView1.Items.Add(lsvpaarent)
Next
end sub
问问题
1614 次