Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net GDI+;中发生一般性错误;更新时_Vb.net_Gdi+ - Fatal编程技术网

Vb.net GDI+;中发生一般性错误;更新时

Vb.net GDI+;中发生一般性错误;更新时,vb.net,gdi+,Vb.net,Gdi+,更新表单时,只有在不更新(更改)图像时才会出现此错误。 当我用新图像更新时,我没有这个错误 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(

更新表单时,只有在不更新(更改)图像时才会出现此错误。
当我用新图像更新时,我没有这个错误

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()
我试着这样做,然后工作

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()

我根本不明白你的代码是怎么工作的。在第一行中,您正在初始化一个没有给定任何参数的新MemoryStream,然后立即尝试从中获取图像?另外,请确定导致异常的确切代码行,并发布完整的异常详细信息。当我不更新(更改)图像时,您的代码显示正在传递的图像数据是什么意思。除了上面的代码之外,还有很多错误的地方)不要使用<代码> GETBuffER()/<代码>,使用<代码> ToArray < /代码> -考虑根本不保存图像,而是保存到某个归档位置的文件的名称;b) 不要使用
AddWithValue()DataReader@DeanOC不幸的是,对于该错误,
一般错误…
是详细信息。不要使用
GetBuffer()
,使用
ToArray()
MSDN上清楚地列出了缺点。。。