tags:

views:

23

answers:

2

I have Fileupload control in asp.net page if i upload my resume(.doc extension) then it should be stored in SQL database how?

A: 

Hi Dominic,

In case you are using Linq To Sql:

protected void BtnUpload_Click(object sender, EventArgs e)

{

 if (FileUploader.HasFile && FileUploader.PostedFile.ContentLength > 0)
  {
      string file = txtFile.Text;
      byte[] filebyte = FileUploader.FileBytes;
      System.Data.Linq.Binary fileBinary = new System.Data.Linq.Binary(filebyte);
      MuseDataContext museData = new MuseDataContext();
      museData.ADDFILE(file, fileBinary);
  }

}

Remember: we need to pass the FileUploader.FileBytes to the constructor of System.Data.Linq.Binary. Byte[] does not map directly to System.Linq.Binary.

Hope this helps

Muse VSExtensions