da, dt, dtglist
Hello!
Could you explain what is da, dt and dtglist in your code? I guess i need declaration for them.
Imports MySql.Data.MySqlClient
and Imports System.IO
above the Public Class for you imports.
Go back to the design view, click the Retrieve button inside the second form to open the click event handler of it. After that do the following code for retrieving data from MySQL database into the datagridview.
Try con.Open() cmd = New MySqlCommand With cmd .Connection = con .CommandText = "SELECT ImageID,Caption FROM tblimageblob" End With da = New MySqlDataAdapter da.SelectCommand = cmd dt = New DataTable da.Fill(dt) With dtglist .DataSource = dt End With Catch ex As Exception MsgBox(ex.Message) Finally da.Dispose() con.Close() End Try
Try con.Open() cmd = New MySqlCommand With cmd .Connection = con .CommandText = "SELECT Caption,ImageFile FROM tblimageblob WHERE ImageID=" & Val(dtglist.CurrentRow.Cells(0).FormattedValue) End With da = New MySqlDataAdapter dt = New DataTable Dim arrImage() As Byte da.SelectCommand = cmd da.Fill(dt) txtCaption.Text = dt.Rows(0).Item(0) arrImage = dt.Rows(0).Item(1) Dim mstream As New System.IO.MemoryStream(arrImage) PictureBox1.Image = Image.FromStream(mstream) Catch ex As Exception MsgBox(ex.Message) Finally da.Dispose() con.Close() End Try