I am working on a report and wanted to generate an excel file from data. I have created a stored procedure which returns multiple datasets and because I am using EF which only supports single dataset, I opted to use below code
using (var connection = mydbcontext.Database.Connection)
{
connection.Open();
var command = connection.CreateCommand();
command.CommandText = string.Format(@"EXEC prDailyRouteReport
{0}",refId);
using (var reader = command.ExecuteReader())
{
//reading data and fetch next result
}
connection.Close()
}
Now the issue is, when I need to call two separate reports within a single web request the connection variable returns empty connection string on the second report. but I didn't get the issue if I remove the using block. I want to know why im getting empty connection string with using statement.
SqlConnectionand do good oldSqlCommand?