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






SqlConnection properties

SqlConnection properties

using System;
using System.Data;
using System.Data.SqlClient;

class MySqlConnection {
  public static void Main() {
    string connectionString = "server=(local)\\SQLEXPRESS;database=MyDatabase;Integrated Security=SSPI";

    SqlConnection mySqlConnection = new SqlConnection(connectionString);

    mySqlConnection.Open();

    Console.WriteLine("mySqlConnection.ConnectionString = "+mySqlConnection.ConnectionString);
    Console.WriteLine("mySqlConnection.ConnectionTimeout = "+mySqlConnection.ConnectionTimeout);
    Console.WriteLine("mySqlConnection.Database = "+mySqlConnection.Database);
    Console.WriteLine("mySqlConnection.DataSource = "+mySqlConnection.DataSource);
    Console.WriteLine("mySqlConnection.PacketSize = "+mySqlConnection.PacketSize);
    Console.WriteLine("mySqlConnection.ServerVersion = "+mySqlConnection.ServerVersion);
    Console.WriteLine("mySqlConnection.State = "+mySqlConnection.State);
    Console.WriteLine("mySqlConnection.WorkstationId = "+mySqlConnection.WorkstationId);

    mySqlConnection.Close();
  }
}
           
       








Related examples in the same category

1.WorkstationId
2.ConnectionTimeout
3.PacketSize
4.Connection String
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