我有很多超过1 mb的图像,我需要在MySQL中保存。有时它可以更新1 mb大小的图像,但有时甚至无法保存500 kb图像。
我已经在MySQL Server 5.0的my.ini文件中将max_allowed_packet更改为32M。
这是我保存图片的代码。我在这里做错了吗?
Try
Dim FileSize As UInt32
Dim mstream As New System.IO.MemoryStream()
pic_box_save.Image.Save(mstream, System.Drawing.Imaging.ImageFormat.Jpeg)
Dim arrImage() As Byte = mstream.GetBuffer()
FileSize = mstream.Length
mstream.Close()
' MsgBox(FileSize)
MyConnection()
Sql = "update AREA set AREA_NAME=@Aname, AREA_IMG=@image_data where AREA_NO='" & cboAreaNo.Text & "'"
Dim cmd As New MySqlCommand(Sql, Con)
cmd.Parameters.AddWithValue("@Aname", txtAreaname.Text)
cmd.Parameters.AddWithValue("@image_data", arrImage)
cmd.ExecuteNonQuery()
MsgBox("Data successfully updated!!", vbInformation, "Updating")
Con.Close()
Catch ex As Exception
MsgBox("Data not Saved!!!" + ex.Message, vbCritical, "System message")
End Try
答案 0 :(得分:0)
我只需要添加
randomLabel.textColor