OleDbConnection: ConnectionTimeout : OdbcCommand « Database ADO.net « C# / C Sharp






OleDbConnection: ConnectionTimeout

 

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

class MainClass {
    public static void Main() {
        using (OleDbConnection con = new OleDbConnection()) {
            con.ConnectionString = "Provider=SQLOLEDB;" +     
                @"Data Source=.\sqlexpress;" + 
                "Initial Catalog=Northwind;" + 
                "Integrated Security=SSPI";    

            con.Open();

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

 








Related examples in the same category

1.Create database through OdbcCommand
2.Pass parameters to OdbcCommand
3.Read query result from OdbcCommand
4.how to execute a TableDirect command