I want to save an image from my C# form application to SQL Server Database, currently i m doing this: In class library class named PhotoCL:
public void AddPhoto(int id, Image photo)
{
db.ExecuteNonQuery("spAddPhoto", new object[] { id, photo});
}
"spAddPhoto" is the stored Procedure which have 2 parameters, @id int
, @img image
In database the table of photos also have two columns with same data types as mentioned above in SP.
This is the Code behind my AddPhoto Button:
private void button1_Click(object sender, EventArgs e)
{
mp.AddPhoto(Convert.ToInt32(comboBox1.SelectedValue),pictureBox1.Image);
}
I m getting this error at runtime(Debugging):
"Failed to convert parameter value from a Bitmap to a Byte[]."
Please help me out.. Thanks in advance..