I am currently using Microsoft Data Library 5.0 to execute a stored procedure.
Database myDatabase = DatabaseFactory.CreateDatabase();
using (DbCommand command = myDatabase.GetStoredProcCommand("myStoredProc"))
{
using (IDataReader dataReader = myDatabase.ExecuteReader(command))
{
while (dataReader.Read())
{
}
}
}
Everything works, but it takes a long time to start. When I turn on SQL Profiler, I see that the stored procedure takes about 50 seconds. However, if I take the same scripts from Profiler and run them inside SQL Management Studio, it takes only about 480 milliseconds to return all rows.
Has anyone encountered this problem? Why is there a big difference?
source
share