using System;
using System.Data;
using System.Data.SqlClient;
class Program
{
static void Main(string[] args)
{
string sqlConnectString = "Data Source=(local);Integrated security=SSPI;Initial Catalog=AdventureWorks;";
SqlConnection connection = new SqlConnection( );
connection.StateChange += new StateChangeEventHandler(connection_StateChange);
connection.ConnectionString = sqlConnectString +
"Connection Timeout=15;Connection Lifetime=0;" +
"Min Pool Size=0;Max Pool Size=100;Pooling=true;";
Console.WriteLine("Connection string = {0}",connection.ConnectionString);
connection.Open();
connection.Close();
connection.ConnectionString = sqlConnectString +
"Connection Timeout=30;Connection Lifetime=0;" +
"Min Pool Size=0;Max Pool Size=200;Pooling=true;";
Console.WriteLine("\nConnection string = {0}",connection.ConnectionString);
connection.Open();
connection.Close();
}
static void connection_StateChange(object sender, StateChangeEventArgs e)
{
Console.WriteLine("\tOriginalState = {0}", e.OriginalState.ToString());
Console.WriteLine("\tCurrentState = {0}", e.CurrentState.ToString());
}
}