Connection String : SqlConnection « Database ADO.net « C# / C Sharp






Connection String

 

using System;
using System.Data.SqlClient;

class MainClass {
    public static void Main() {
        using (SqlConnection con = new SqlConnection()) {
            con.ConnectionString =
               @"Data Source = .\sqlexpress;" +// local SQL Server instance
               "Database = Northwind;" +       // the sample Northwind DB
               "Integrated Security = SSPI;" + // integrated Windows security
               "Min Pool Size = 5;" +          // configure minimum pool size
               "Max Pool Size = 15;" +         // configure maximum pool size
               "Connection Reset = True;" +    // reset connections each use
               "Connection Lifetime = 600";    // set max connection lifetime
            con.Open();
        }

        using (SqlConnection con = new SqlConnection()) {
            con.ConnectionString =
                @"Data Source = .\sqlexpress;" +//local SQL Server instance
                "Database = Northwind;" +       //the sample Northwind DB
                "Integrated Security = SSPI;" + //integrated Windows security
                "Pooling = False";              //specify nonpooled connection
            con.Open();
        }

    }
}

 








Related examples in the same category

1.SqlConnection propertiesSqlConnection properties
2.WorkstationId
3.ConnectionTimeout
4.PacketSize
5.DataSource
6.SqlConnection state change event
7.SqlConnection: info message event handler
8.Connect to Access database
9.Creating SQL Connections
10.Create SqlCommand object