using System;
using System.Data.SqlClient;
class Program
{
static void Main(string[] args)
{
SqlConnectionStringBuilder csb = new SqlConnectionStringBuilder( );
csb.DataSource = "(local)";
csb.Add("Initial Catalog", "AdventureWorks");
csb["Integrated Security"] = true;
Console.WriteLine("Connection string:\n{0}", csb.ConnectionString);
SqlConnection connection = new SqlConnection(csb.ConnectionString);
connection.Open( );
Console.WriteLine("\nConnectionState = {0}", connection.State);
connection.Close( );
Console.WriteLine("ConnectionState = {0}", connection.State);
}
}