I am using SqlCommand
to perform a query, however this query is very slow in general - taking about 50 seconds to complete - is there anyway I can read the results as they come in one by one?
using (SqlConnection connection = new SqlConnection(ExportMetrics.CreateConnectionString()))
{
SqlCommand command = new SqlCommand(sqlQuery, connection);
connection.Open();
SqlDataReader reader = command.ExecuteReader();
try
{
while (reader.Read())
{
//Read results
}
catch (Exception e)
{
//Exception
}
finally
{
reader.Close();
}
}
}