Here is my problem.
We have 2 types of reports on our website, data displayed in the grid, and data that are instantly downloaded as a report.
These reports may contain several years of data (1 + million rows), we allow our customers to upload data with a date range, but we began to limit how long they can view the data in order to prevent performance problems in our website. However, the data is still getting quite large even on a small date range, now that it expands and if it loads too much, our memory accumulates at several concerts and ends from memory.
Question: I rather do not limit their data, so I try to find a good solution that allows them to download as much as they want.
I can limit what they see only by returning data to the page, so there is no performance issue, however loading is always a problem.
I looked at async but couldn't get it to work as it accumulates memory when I load data.
Ideas? Thoughts? Suggestions?
Code example:
// Get Data
SqlConnection con = new SqlConnection ();
SqlCommand cmd = new SqlCommand ();
SqlDataAdapter da;
DataSet ds = new DataSet ();
con.ConnectionString = "MyConnectionString";
con.Open ();
cmd.Connection = con;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "MyStoredProc";
da = new SqlDataAdapter (cmd);
da.Fill (ds);
con.Close ();
StringWriter sw = new StringWriter ();
HtmlTextWriter htw = new HtmlTextWriter (sw);
DataGrid dg = new DataGrid ();
dg.DataSource = ds.Tables [0];
dg.DataBind ();
dg.RenderControl (htw);
Response.ClearContent ();
Response.ContentType = "application / vnd.ms-excel";
Response.AddHeader ("Content-Disposition", "attachment; filename = Report.xls");
Response.Write (sw.ToString ());
Response.End ();
When I run this with my data, which is approximately 800 thousand lines, my memory bursts and I get an error from the memory, and also worsen the situation .. it always freezes in the RenderControl until it finishes
source share