Hardik Patel

Hardik Patel

  • NA
  • 378
  • 468.4k

how to insert image in sql server 2008 in .net?

Sep 23 2013 12:53 AM
how to insert image in sql server 2008 in .net?

i am using below code


string str;
FileUpload img = (FileUpload)imgUpload;
            Byte[] imgByte = null;
            if (img.HasFile && img.PostedFile != null)
            {
                HttpPostedFile File = imgUpload.PostedFile;
                imgByte = new Byte[File.ContentLength];
                File.InputStream.Read(imgByte, 0, File.ContentLength);
        

    }
str ="Insert into tblimg values ('"+imgByte.tostring()+"')";



it's not working

Answers (3)