By using this code you can save the image file as binary.
In database create two fields
1.Image varbinary
2.ImageId varchar
protected void btnsave2_Click(object sender, EventArgs e)
{
imag++;
byte[] imagebyte = new byte[FileUpload1.PostedFile.InputStream.Length + 1];
FileUpload1.PostedFile.InputStream.Read(imagebyte, 0, imagebyte.Length);
cmd = new MySqlCommand("Insert Into db_image (Image,ImageId) values (@imag,@imageid)", con);
cmd.Parameters.AddWithValue("imag", imagebyte);
cmd.Parameters.AddWithValue("imageid", imag.ToString());
cmd.ExecuteNonQuery();
}
protected void btnretr2_Click(object sender, EventArgs e)
{
cmd = new MySqlCommand("Select Image from db_image where ImageId='" +txt_imageid.Text.Trim()+ "' ", con);
dr = cmd.ExecuteReader();
while (dr.Read())
{
Response.BinaryWrite((byte[])dr["Image"]);
}
}