一般错误发生GDI +

时间:2015-05-08 03:41:34

标签: vb.net

我的更新按钮:

'MYSQL CODE

    Dim con As MySqlConnection = New MySqlConnection("server=shhh;user id=root;Password=shhhh;database=member")
    Dim reader As MySqlDataReader
    'insert image
    Dim mstream As New System.IO.MemoryStream()
    pic.Image.Save(mstream, System.Drawing.Imaging.ImageFormat.Png)
    Dim arrimage() As Byte = mstream.GetBuffer()
    mstream.Close()
    Try
        con.Open()
        Dim query As String
        Dim command As MySqlCommand
        query = "Update doxdb set aliases='" & Aliases.Text & "',ualiases='" & ualiases.Text & "', fullname='" & fullname.Text & "', address='" & address.Text & "', address2='" & address2.Text & "', address3='" & address3.Text & "', relative1='" & relative1.Text & "', relative2='" & relative2.Text & "', relative3='" & relative3.Text & "', relative4='" & relative4.Text & "', phone='" & phone.Text & "', ipaddress='" & ipaddress.Text & "', email='" & email.Text & "', email2='" & email2.Text & "', facebook='" & facebook.Text & "', instagram='" & instagram.Text & "', dod='" & dod.Text & "', dob='" & dob.Text & "', twitter='" & twitter.Text & "', skype='" & skype.Text & "', notes='" & notes.Text & "', pic = @pic where aliases='" & Aliases.Text & "'"
        command = New MySqlCommand(query, con)
        command.Parameters.AddWithValue("@pic", arrimage)

        reader = command.ExecuteReader

        MessageBox.Show("data saved")

        con.Close()


    Catch ex As Exception
        MessageBox.Show(ex.Message)
    Finally
        con.Dispose()

    End Try

我选择的图片按钮:

 With ofdImage
        .InitialDirectory = "C:"
        .Filter = "Only Picture With JPG/JPEG/PNG Extension|*.jpg;*.jpeg;*.png"
        .FileName = Nothing
    End With
    If ofdimage.ShowDialog = Windows.Forms.DialogResult.OK Then
        pic.BackgroundImageLayout = ImageLayout.Stretch
        pic.Image = Image.FromFile(ofdimage.FileName)
        pic.Tag = ofdimage.FileName
    Else
        pic.Tag = ""
    End If

它抛出了我的例外:

************** Exception Text **************
System.Runtime.InteropServices.ExternalException (0x80004005): A generic error occurred in GDI+.
   at System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams)
   at System.Drawing.Image.Save(Stream stream, ImageFormat format)
   at wIDox.doxdb.NyX_Button4_Click_2(Object sender, EventArgs e)
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

这就是我想要做的事情:

http://i.stack.imgur.com/JsugR.png

上传图片后,不会让您更新图片并继续抛出此错误。我不知道该怎么做,如果您需要更多信息或代码,请告诉我,我想尽快完成这项工作,我尽量为您提供尽可能多的信息以弥补我的旧问题谢谢!

0 个答案:

没有答案