У меня есть этот код для вставки данных
Private Sub btnsave_Click(sender As System.Object, e As System.EventArgs) Handles btnsave.Click
Dim mstream As New System.IO.MemoryStream()
testpb.Image.Save(mstream, System.Drawing.Imaging.ImageFormat.Jpeg)
Dim arrImage() As Byte = mstream.GetBuffer()
MysqlConn = New MySqlConnection
MysqlConn.ConnectionString =
"server=localhost;userid=root;password=rico;database=god;"
Dim READER As MySqlDataReader
Try
MysqlConn.Open()
COMMAND.Connection = MysqlConn
COMMAND.CommandType = CommandType.Text
COMMAND.CommandText = "insert into god.precord (ID,LastName,FirstName,MiddleName,Address,ContactNo,Gender,Birthdate,Age,picture) values ('" & txtid.Text & "','" & txtlastname.Text & "','" & txtfirstname.Text & "','" & txtmiddlename.Text & "','" & txtaddress.Text & "','" & txtcontactno.Text & "','" & txtgender.Text & "','" & dtpbirthdate.Text & "','" & txtage.Text & "',@picture)"
COMMAND.Parameters.AddWithValue("@picture", arrImage)
READER = COMMAND.ExecuteReader
MessageBox.Show("Data Saved")
MysqlConn.Close()
Catch ex As MySqlException
MessageBox.Show(ex.Message)
Finally
MysqlConn.Dispose()
End Try
dbDataSet.Clear()
load_table()
End Sub
Я знал, как получить некоторые данные обратно в мои текстовые поля. Проблема в том, что я не знал, как вернуть изображение обратно в PictureBox, просто щелкнув содержимое ячейки моего Datagridview.
Вот мой код для получения некоторых данных обратно в мои текстовые поля
If e.RowIndex >= 0 Then
Dim row As DataGridViewRow
row = Me.DataGridView1.Rows(e.RowIndex)
txtid.Text = row.Cells("ID").Value.ToString
txtlastname.Text = row.Cells("LastName").Value.ToString
txtfirstname.Text = row.Cells("FirstName").Value.ToString
txtmiddlename.Text = row.Cells("MiddleName").Value.ToString
txtaddress.Text = row.Cells("Address").Value.ToString
txtcontactno.Text = row.Cells("ContactNo").Value.ToString
txtgender.Text = row.Cells("Gender").Value.ToString
dtpbirthdate.Text = row.Cells("Birthdate").Value.ToString
txtage.Text = row.Cells("Age").Value.ToString
End If
Спасибо за любую помощь, которую вы можете предложить.