Re: Uploading Large File to SQL
From: Steve C. Orr [MVP, MCSD] (Steve_at_Orr.net)
Date: 07/13/04
- Next message: Eliyahu Goldin: "Re: Apply css to asp:HyperLinkColumn"
- Previous message: Kyril Magnos: "Re: Urgent: Integrate WebBrowser Control in ASP.NET/VB.NET?"
- In reply to: - Steve -: "Re: Uploading Large File to SQL"
- Next in thread: Joe Fallon: "Re: Uploading Large File to SQL"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 13 Jul 2004 10:56:51 -0700
Yes you need a lot of memory on your web server(s) if you're going to be dealing with files of that size.
Here's a third party product that improves the efficiency and scalability of such tasks:
www.safileup.com
-- I hope this helps, Steve C. Orr, MCSD, MVP http://Steve.Orr.net "- Steve -" <sevans@foundation.sdsu.edu> wrote in message news:eNDKHFQaEHA.2908@TK2MSFTNGP10.phx.gbl... Okay that fixed the problem. However now when I'm upload a 500+mb file I run out of memory on the web server. Is there a better way to do this where I can stream the data in instead of creating such a huge byte[] variable. -- Steve Evans Email Services SDSU Foundation (619) 594-0708 "Steve C. Orr [MVP, MCSD]" <Steve@Orr.net> wrote in message news:%23NLCZ3PaEHA.712@TK2MSFTNGP11.phx.gbl... You can add or modify the following section in your web.config file: <configuration> <system.web> <httpRuntime maxRequestLength="4096" /> </system.web> </configuration> The above value (4096 KB) is the default maximum upload file size. -- I hope this helps, Steve C. Orr, MCSD, MVP http://Steve.Orr.net "- Steve -" <sevans@foundation.sdsu.edu> wrote in message news:un7FmBPaEHA.2520@TK2MSFTNGP12.phx.gbl... I have the following function that is supposed to save a file to a SQL server. It works fine when the file is under about 5mb, but bigger than that and after I hit submit (which eventually fires off this function) it get a 400 page error. private void btnUpload_Click(object sender, System.EventArgs e) { HttpPostedFile myFile = fileUpload.PostedFile; byte[] myFileData = new byte[myFile.ContentLength]; myFile.InputStream.Read(myFileData, 0, myFile.ContentLength); string fileName = Path.GetFileName(myFile.FileName); SaveFileToSQL(fileName, myFile.ContentType, ref myFileData); } private string SaveFileToSQL(string fileName, string fileType, ref byte[] fileData) { SqlConnection myConnection = new SqlConnection(<connection details>) SqlDataAdapter myDataAdapter = new SqlDataAdapter("SELECT * FROM FileX", myConnection); SqlCommandBuilder myCommandBuilder = new SqlCommandBuilder(myDataAdapter); myConnection.Open(); DataSet myDataSet = new DataSet(); myDataAdapter.Fill(myDataSet, "FileX"); DataTable myDataTable = myDataSet.Tables["FileX"]; //insert data into SQL DataRow myDataRow = myDataTable.NewRow(); myDataRow["FileName"] = fileName; myDataRow["FileSize"] = fileData.Length; myDataRow["ContentType"] = fileType; myDataRow["FileData"] = fileData; myDataTable.Rows.Add(myDataRow); myDataAdapter.Update(myDataSet, "FileX"); myConnection.Close(); } -- Steve Evans Email Services SDSU Foundation (619) 594-0708
- Next message: Eliyahu Goldin: "Re: Apply css to asp:HyperLinkColumn"
- Previous message: Kyril Magnos: "Re: Urgent: Integrate WebBrowser Control in ASP.NET/VB.NET?"
- In reply to: - Steve -: "Re: Uploading Large File to SQL"
- Next in thread: Joe Fallon: "Re: Uploading Large File to SQL"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|