I have Fileupload control in asp.net page if i upload my resume(.doc extension) then it should be stored in SQL database how?
+2
A:
Check this link : http://www.dotnetthoughts.net/2009/10/07/how-to-store-and-retrieve-files-from-sql-server-database/
Anuraj
2010-04-29 11:18:38
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
2010-04-30 20:39:38