I am using the following function to store image in db
void SaveImage(byte[] image)
{
MySqlConnection con = new MySqlConnection(db);//new connection is made
con.Open();
string cmdText = "INSERT INTO Picture(RoomNo ,pic )VALUES ('" + RoomNo.Text + "',?Image)";
MySqlCommand cmd = new MySqlCommand(cmdText, con);
cmd.Parameters.Add("?Image", image);
cmd.ExecuteNonQuery();
}
In main I am calling the function like this
using (var ms = new MemoryStream())
{
picbox.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
SaveImage(ms.ToArray());
}
I do not know how to display it in a picture box .. can any one help me???
Are you using Windows Forms? And you must Convert Byte array to Image for displaying it in Picture Box.
And how did you convert Image to byte array. I hope that problem not there. You can use: