0

I have a web forms page built in C# that takes user input to search an SQL Server 2012 database. The page then exports the results to excel using EPPlus.

I have just optimised all my SQL and the stored procedure the page uses now runs in under a second in SSMS but takes around 30s on the page.

When I have debugged this the hold up is when the datatable is being populated on the myDataAdaptor.Fill(myDataTable); in the following code, all other code runs instantly.

var myDataAdaptor = new SqlDataAdapter(myCommand);

using (myConnection)
using (myCommand)
using (myDataAdaptor)
{
    myDataAdaptor.Fill(myDataTable); //Hold up happens here
}

return myDataTable;

The datatable is returned and then passed to the EPPlus code and the spreadsheet is generated, I have used a datatable as all EPPlus examples i have found use datatables.

Any help on speeding this up would be greatly appreciated.

Simon
  • 1,293
  • 5
  • 21
  • 39

0 Answers0