Re: Uploading Large File to SQL

From: Joe Fallon (jfallon1_at_nospamtwcny.rr.com)
Date: 07/20/04


Date: Mon, 19 Jul 2004 22:00:11 -0400

I have read a lot of stuff and have not seen it.
But you never know...

-- 
Joe Fallon
  "- Steve -" <sevans@foundation.sdsu.edu> wrote in message news:eHkZMadbEHA.216@TK2MSFTNGP10.phx.gbl...
  Any plans to cover this in ASP.net 2.0?
  -- 
  Steve Evans
  Email Services
  SDSU Foundation
  (619) 594-0708
    "Joe Fallon" <jfallon1@nospamtwcny.rr.com> wrote in message news:uGCZi4haEHA.752@TK2MSFTNGP09.phx.gbl...
    There is no simple built in way to do it.
    You should buy a 3rd party product if you need that ability.
    There is an old thread (that is huge) that discussed this issue for over a year.
    They came up with 90% of the code required to do this and then "went quiet".
    Then 3rd party controls started being sold.
    Coincidence? I think not.
    -- 
    Joe Fallon
     
      "- 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


Relevant Pages

  • Re: Uploading Large File to SQL
    ... Joe Fallon ... SDSU Foundation ... private string SaveFileToSQL ... SqlDataAdapter myDataAdapter = new SqlDataAdapter ...
    (microsoft.public.sqlserver.programming)
  • Re: Uploading Large File to SQL
    ... Steve Evans ... SDSU Foundation ... private string SaveFileToSQL ... SqlDataAdapter myDataAdapter = new SqlDataAdapter ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Uploading Large File to SQL
    ... Steve Evans ... SDSU Foundation ... private string SaveFileToSQL ... SqlDataAdapter myDataAdapter = new SqlDataAdapter ...
    (microsoft.public.sqlserver.programming)
  • Re: Pack a linked DB file
    ... > "Joe Fallon" wrote in message ... lpReserved As String ... >> Public Sub ShellWait ... >> pack all .dbf files in the folder. ...
    (microsoft.public.access.externaldata)
  • Re: Cbool problem
    ... Once I input a good sample string it ran correctly. ... > permissions to write to the directory. ... > "Joe Fallon" wrote in message ... >> I am now trying to use dynamic code execution in an ASP.Net application. ...
    (microsoft.public.dotnet.languages.vb)