Ferhat Gürsu
New member
i can save on windows xp, this code, but same code dont save image on mysql database on windows 7
Dim ms As MemoryStream = New MemoryStream
PictureBox1.Image.Save(ms, Imaging.ImageFormat.Jpeg)
Dim bytBLOBData(ms.Length - 1) As Byte
ms.Position = 0
ms.Read(bytBLOBData, 0, ms.Length)
Dim prm As New MySql.Data.MySqlClient.MySqlParameter("@BLOBData", MySql.Data.MySqlClient.MySqlDbType.LongBlob, _
bytBLOBData.Length, ParameterDirection.Input, False, _
0, 0, Nothing, DataRowVersion.Current, bytBLOBData)
Dim ekle As New MySql.Data.MySqlClient.MySqlCommand("update ogrenci set resim=@BLOBData where id='" & ogrid & "'", cnn)
ekle.CommandType = CommandType.Text
ekle.Parameters.Add(prm)
cnn.Close()
cnn.Open()
ekle.ExecuteNonQuery()
cnn.Close()
Dim ms As MemoryStream = New MemoryStream
PictureBox1.Image.Save(ms, Imaging.ImageFormat.Jpeg)
Dim bytBLOBData(ms.Length - 1) As Byte
ms.Position = 0
ms.Read(bytBLOBData, 0, ms.Length)
Dim prm As New MySql.Data.MySqlClient.MySqlParameter("@BLOBData", MySql.Data.MySqlClient.MySqlDbType.LongBlob, _
bytBLOBData.Length, ParameterDirection.Input, False, _
0, 0, Nothing, DataRowVersion.Current, bytBLOBData)
Dim ekle As New MySql.Data.MySqlClient.MySqlCommand("update ogrenci set resim=@BLOBData where id='" & ogrid & "'", cnn)
ekle.CommandType = CommandType.Text
ekle.Parameters.Add(prm)
cnn.Close()
cnn.Open()
ekle.ExecuteNonQuery()
cnn.Close()