OleDbConnection: ConnectionString property : OleDbConnection « Database ADO.net « C# / C Sharp






OleDbConnection: ConnectionString property

 

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("  Connection String = " +
                    con.ConnectionString);
            } else {
                Console.WriteLine("OleDbConnection failed to open.");
                Console.WriteLine("  Connection State = " + con.State);
            }
        }
    }
}

 








Related examples in the same category

1.OleDbConnection connection: ConnectionString, Database, DataSource, ServerVersion and State
2.Read data from ole db connection
3.OleDbConnection string
4.OleDbConnection: State
5.OleDbConnection: DataSource
6.OleDbConnection: Database
7.OleDbConnection: ServerVersion