Hi
i want to save image from picturebox into sql but i got the error 'ARTHEMATIC OPERATIONS RESULTED IN AN OVERFLOW' On line
bytBLOBData = New Byte() {ms.Length}
here is my code
sqlConnection = New SqlClient.SqlCo nnection(sConne ctionString)
sqlCommand = New SqlClient.SqlCo mmand("INSERT INTO BLOBTest (BLOBData) VALUES (@BLOBData)", sqlConnection)
'//Save image from PictureBox into MemoryStream object.
ms = New MemoryStream()
PictureBox1.Ima ge.Save(ms, ImageFormat.Jpe g)
'//Read from MemoryStream into Byte array.
bytBLOBData = New Byte() {ms.Length} // ERROR IS HERE
ms.Position = 0
ms.Read(bytBLOB Data, 0, Convert.ToInt32 (ms.Length))
'//Create parameter for insert statement that contains image.
prm = New SqlClient.SqlPa rameter("@BLOBD ata", SqlDbType.VarBi nary, bytBLOBData.Len gth, ParameterDirect ion.Input, False, 0, 0, "BLOBData", DataRowVersion. Current, bytBLOBData)
sqlCommand.Para meters.Add(prm)
sqlConnection.O pen()
sqlCommand.Exec uteNonQuery()
sqlConnection.C lose()
PLEASE GIVE ME SOME SOLUTION
VARINDER
i want to save image from picturebox into sql but i got the error 'ARTHEMATIC OPERATIONS RESULTED IN AN OVERFLOW' On line
bytBLOBData = New Byte() {ms.Length}
here is my code
sqlConnection = New SqlClient.SqlCo nnection(sConne ctionString)
sqlCommand = New SqlClient.SqlCo mmand("INSERT INTO BLOBTest (BLOBData) VALUES (@BLOBData)", sqlConnection)
'//Save image from PictureBox into MemoryStream object.
ms = New MemoryStream()
PictureBox1.Ima ge.Save(ms, ImageFormat.Jpe g)
'//Read from MemoryStream into Byte array.
bytBLOBData = New Byte() {ms.Length} // ERROR IS HERE
ms.Position = 0
ms.Read(bytBLOB Data, 0, Convert.ToInt32 (ms.Length))
'//Create parameter for insert statement that contains image.
prm = New SqlClient.SqlPa rameter("@BLOBD ata", SqlDbType.VarBi nary, bytBLOBData.Len gth, ParameterDirect ion.Input, False, 0, 0, "BLOBData", DataRowVersion. Current, bytBLOBData)
sqlCommand.Para meters.Add(prm)
sqlConnection.O pen()
sqlCommand.Exec uteNonQuery()
sqlConnection.C lose()
PLEASE GIVE ME SOME SOLUTION
VARINDER
Comment