当我更新表单时,只有在我不更新(更改)图像时才会出现此错误 当我使用新图片更新时,我没有出现此错误。
Try
Dim mstream As New System.IO.MemoryStream()
PictureBox1.Image = New Bitmap(Image.FromStream(mstream))
Dim arrImage() As Byte = mstream.GetBuffer()
mstream.Close()
MysqlConn.Close()
MysqlConn.Open()
COMMAND.Connection = MysqlConn
COMMAND.CommandText = "update product set
id_maker=@Value1,
foto=@foto
where id = '" & TextBox1.Text & "'"
COMMAND.Parameters.AddWithValue("@Value1", If(String.IsNullOrEmpty(ComboBox1.Text), DBNull.Value, ComboBox1.Text))
COMMAND.Parameters.AddWithValue("@foto", arrImage)
READER = COMMAND.ExecuteReader
MessageBox.Show("Datos Guardados")
MysqlConn.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
MysqlConn.Dispose()
End Try
MysqlConn.Close()
答案 0 :(得分:-2)
我试试这个并且工作。
Dim mstream As New System.IO.MemoryStream()
'PictureBox1.Image = New Bitmap(Image.FromStream(mstream))
PictureBox1.Image.Save(mstream, System.Drawing.Imaging.ImageFormat.Jpeg)
Dim arrImage() As Byte = mstream.GetBuffer()