Build a connection string from component parameters and display it : SqlConnectionStringBuilder « ADO.Net « C# / CSharp Tutorial






using System;
using System.Data.SqlClient;

class MainClass
{
    public static void Main(string[] args)
    {
        
        SqlConnectionStringBuilder sb2 = new SqlConnectionStringBuilder();

        sb2.DataSource = @".\sqlexpress";
        sb2.InitialCatalog = "Northwind";
        sb2.IntegratedSecurity = true;
        sb2.MinPoolSize = 5;
        sb2.MinPoolSize = 15;
        sb2.LoadBalanceTimeout = 600;
        sb2.ConnectionReset = true;

        Console.WriteLine("Constructed connection string:");
        Console.WriteLine("  " + sb2.ConnectionString);
    }
}
Constructed connection string:
  Data Source=.\sqlexpress;Initial Catalog=Northwind;Integrated Security=True;Min Pool Size=15;Conne
ction Reset=True;Load Balance Timeout=600








32.16.SqlConnectionStringBuilder
32.16.1.Build SqlConnectionStringBuilder from connection string
32.16.2.Build a connection string from component parameters and display it
32.16.3.BuildConnectionString solution