DataSource : SqlConnection « Database ADO.net « C# / C Sharp






DataSource

 
using System;
using System.Data.SqlClient;

class MainClass {
    public static void Main(string[] args) {
        string conString = @"Data Source=.\sqlexpress;" +
            "Database=Northwind;Integrated Security=SSPI;" +
            "Min Pool Size=5;Max Pool Size=15;Connection Reset=True;" +
            "Connection Lifetime=600;";

        SqlConnectionStringBuilder sb1 = new SqlConnectionStringBuilder(conString);
        Console.WriteLine("  Database Source = " + sb1.DataSource);

        SqlConnectionStringBuilder sb2 = new SqlConnectionStringBuilder(conString);

        sb2.DataSource = @".\sqlexpress";

        Console.WriteLine("  " + sb2.ConnectionString);

    }
}

 








Related examples in the same category

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