Image to to Stream of Byte[]?
Image to to Stream of Byte[]?
I have an image in the pictureBox captured from a device.Now i want to convert this PicBox.Image to stream of bytes to save it in the DataBase.Plz help me how to convert this image from pictureBox to stream of bytes.I
pretty know how to save it in database but having some problem converting the image to stream of bytes from PictureBox.
Thnx in Advance!
Re: Image to to Stream of Byte[]?
Save the Image to a MemoryStream.
Re: Image to to Stream of Byte[]?
define the parameter for those insert command so that the image get converted to the byte stream while entering into the database.
Re: Image to to Stream of Byte[]?
This works for me...
Save to byte array...
Code:
ImageConverter ic = new ImageConverter();
byte[] imageBuffer = (byte[]) ic.ConvertTo(MyImageVariable, typeof(byte[]));
Call a method that takes the byte array for data update..
Code:
public bool SaveSignature(int userID, byte[] signature)
{
DBCommandWrapper wrapper = _db.GetStoredProcCommandWrapper("CODBA.usr_UpdateSignature");
wrapper.AddInParameter("@UserID", DbType.Int32, buyerID);
wrapper.AddInParameter("@Signature", DbType.Binary, signature);
try
{
_db.ExecuteNonQuery(wrapper);
return true;
}
catch
{
throw;
}
}
Your stored procedure...
Code:
CREATE PROCEDURE CODBA.usr_UpdateSignature
(
@UserID SMALLINT,
@Signature IMAGE
)
AS
etc...normal database update now.