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






ConnectionTimeout

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

class MainClass {
    public static void Main() {
        using (SqlConnection con = new SqlConnection()) {
            con.ConnectionString = @"Data Source=.\sqlexpress;Database=Northwind;Integrated Security=SSPI";    

            con.Open();

            if (con.State == ConnectionState.Open) {
                Console.WriteLine("  Timeout = " + con.ConnectionTimeout);
            } else {
                Console.WriteLine("SqlConnection failed to open.");
                Console.WriteLine("  Connection State = " + con.State);
            }

        }
    }
}

 








Related examples in the same category

1.SqlConnection propertiesSqlConnection properties
2.WorkstationId
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