Jul 9 2006

SQL Server Provider Statistics

Category: ASP.NET 2.0 - GeneralBil@l @ 12:14

SQL Server Provider in .NET Framework 2.0 provides a way to generate per-connection reports for measuring performance through a property in the SqlConnection object called StatisticsEnabled.

This is a sample code of how to do so:

SqlConnection conn = new SqlConnection(connectionString);
conn.Open();
conn.StatisticsEnabled = true;

// Perform data access operations

IDictionary stats = conn.RetrieveStatistics();

foreach (DictionaryEntry e in stats)
{
        Response.Write("Key : " + e.Key + " Value : " + e.Value);       
}

conn.ResetStatistics();



Hope this helps!

Regards

Tags:

Comments are closed