Private Sub showdata()
Dim str As String
Dim da As OleDbDataAdapter
Dim ds As New DataSet
str = String.Format("SELECT * FROM tb_item ORDER BY item_id ")
Try
If isfind = True Then
ds.Tables("item").Clear()
End If
Catch
End Try
da = New OleDbDataAdapter(str, con)
da.Fill(ds, "item")
If ds.Tables("item").Rows.Count >= 0 Then
isfind = True
Try
dts.Clear()
With dts
.Columns.Add("item_id")
.Columns.Add("pic", GetType(Bitmap))
.Columns.Add("item_name")
.Columns.Add("item_size")
.Columns.Add("item_number")
.Columns.Add("item_price")
.Columns.Add("type_name")
.Columns.Add("path")
End With
Catch ex As Exception
End Try
For i = 0 To ds.Tables("item").Rows.Count - 1
Dim itemid As String
Dim name As String
Dim size As String
Dim number As Integer
Dim price As Integer
Dim type As String
Dim pic As String
Dim path As String
itemid = ds.Tables(0).Rows(i)(0).ToString
name = ds.Tables(0).Rows(i)(1).ToString
size = ds.Tables(0).Rows(i)(2).ToString
number = ds.Tables(0).Rows(i)(3).ToString
price = ds.Tables(0).Rows(i)(4).ToString
type = ds.Tables(0).Rows(i)(5).ToString
pic = ds.Tables(0).Rows(i)(6).ToString
path = ds.Tables(0).Rows(i)(6).ToString
Dim getpic As String = My.Application.Info.DirectoryPath & "\PICDATA\" & pic
dts.Rows.Add(itemid, New Bitmap(getpic), name, size, number, price, type, pic)
Next
Else : isfind = False
End If
dts.Clear()
ds.Tables("item").Clear()
DataGridView1.RowTemplate.Height = 80
DataGridView1.DataSource = dts
DataGridView1.ClearSelection()
End Sub
Dim bytes = File.ReadAllBytes(My.Application.Info.DirectoryPath & "\PICDATA\" & pic)
Dim ms As New MemoryStream(bytes)
Dim getpic = Image.FromStream(ms)