using System;
using System.Collections;
using System.Data;
using System.Data.SqlClient;

namespace SqlClientStats
{
	/// <summary>
	/// Summary description for Class1.
	/// </summary>
	class Class1
	{
		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main(string[] args)
		{
			SqlConnection conn = new SqlConnection("server=.;integrated security=sspi;database=pubs");
			conn.Open();

			// Enable
			conn.StatisticsEnabled = true;

			// do some operations
			//
			SqlCommand cmd = new SqlCommand("select * from authors", conn);
			SqlDataReader rdr = cmd.ExecuteReader();

			Hashtable stats = (Hashtable)conn.RetrieveStatistics();

			// process stats
			IDictionaryEnumerator e = stats.GetEnumerator();
			while (e.MoveNext())
				Console.WriteLine("{0} : {1}", e.Key, e.Value);

			conn.ResetStatistics();

		}
	}
}
