I am having a problem saving the images into my sql database. My table design is as following:
id int
VN74_VIN_id int
Stamp Varbinary(MAX)
DVT Varbinary(MAX)
my codes are the following:
Dim stampbarcodecontrol As New BarCodeBuilder
Dim DVTbarcodecontrol As New BarCodeBuilder
stampbarcodecontrol.SymbologyType = Symbology.Code39Extended
stampbarcodecontrol.CodeText = "123456789"
DVTbarcodecontrol.SymbologyType = Symbology.Pdf417
DVTbarcodecontrol.CodeText = "123456789"
Dim StampmStream As System.IO.MemoryStream = New System.IO.MemoryStream()
stampbarcodecontrol.BarCodeImage.Save(StampmStream, System.Drawing.Imaging.ImageFormat.Png)
Dim DVTmStream As System.IO.MemoryStream = New System.IO.MemoryStream
DVTbarcodecontrol.BarCodeImage.Save(DVTmStream, System.Drawing.Imaging.ImageFormat.Png)
Dim Myd1(StampmStream.Length) As Byte
Dim Myd2(DVTmStream.Length) As Byte
StampmStream.Read(Myd1, 0, StampmStream.Length)
DVTmStream.Read(Myd2, 0, DVTmStream.Length)
Try
OpenSqlDatabase_Isuzu()
strSql_Isuzu = "Insert into VN74_Barcode (VN74_VIN_id,Stamp,DVT) Values ('" & vinid & "',@Myd1,@Myd2)"
cmd_Isuzu.Parameters.Add("@Myd1", SqlDbType.VarBinary, StampmStream.Length).Value = Myd1
cmd_Isuzu.Parameters.Add("@Myd2", SqlDbType.VarBinary, DVTmStream.Length).Value = Myd2
cmd_Isuzu.CommandText = strSql_Isuzu
cmd_Isuzu.ExecuteNonQuery()
CloseSqlDatabase_Isuzu()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
It is saving data but when I try to retrieve the images from database to a form in a picturebox or anything it does not show an image.Please check my codes and let me know.Thanks