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

namespace ClientStats
{
	/// <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=AdventureWorks");

			try
			{
				conn.Open();

				// Enable
				conn.StatisticsEnabled = true;

				// do some operations
				//
        SqlCommand cmd = new SqlCommand("select * from person.ContactType", 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();
			}
			catch (Exception e)
			{
				Console.WriteLine(e.Message);
				Console.WriteLine(e.StackTrace);
			}
			finally
			{
				conn.Dispose();
			}
			Console.ReadLine();
		}
	}
}
