It is because of the line
byte[] productImage = FileUpload1.FileBytes;
Instead refer -
Upload images onto SQL Server using ASP.NET webpage[
^]
if (FileUpload1.PostedFile != null
&& FileUpload1.PostedFile.FileName != "")
{
byte[] myimage = new byte[FileUpload1.PostedFile.ContentLength];
HttpPostedFile Image = FileUpload1.PostedFile;
Image.InputStream.Read(myimage, 0, (int)FileUpload1.PostedFile.ContentLength);
SqlConnection myConnection = new SqlConnection("Data Source = ComputerName\\SQLEXPRESS; Initial Catalog= dbname; Integrated Security= SSPI");
SqlCommand storeimage = new SqlCommand("INSERT INTO Image_Gallery "+"(Img_Id, Image_Content, Image_Type, Image_Size) "+" values (3, @image, @imagetype, @imagesize)", myConnection);
storeimage.Parameters.Add("@image", SqlDbType.Image, myimage.Length).Value = myimage;
storeimage.Parameters.Add("@imagetype", SqlDbType.VarChar, 100).Value = FileUpload1.PostedFile.ContentType;
storeimage.Parameters.Add("@imagesize", SqlDbType.BigInt, 99999).Value = FileUpload1.PostedFile.ContentLength;
myConnection.Open();
storeimage.ExecuteNonQuery();
myConnection.Close();
Respone.Write("successfully upload the image");
}
Thanks...