Connection for OleDb : OleDbConnection « ADO.Net « C# / CSharp Tutorial






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

    class ConnectionOleDb
    {
        static void Main()
        {
            OleDbConnection conn = new OleDbConnection(@"provider = sqloledb;data source = .\sqlexpress;integrated security = sspi;");
            try
            {
                conn.Open();
                Console.WriteLine("\tConnection String: {0}",conn.ConnectionString);
                Console.WriteLine("\tDatabase: {0}",conn.Database);
                Console.WriteLine("\tDataSource: {0}",conn.DataSource);
                Console.WriteLine("\tServerVersion: {0}",conn.ServerVersion);
                Console.WriteLine("\tState: {0}",conn.State);
            }
            catch (OleDbException e)
            {
                Console.WriteLine("Error: " + e);
            }
            finally
            {
                conn.Close();
                Console.WriteLine("Connection closed.");
            } 
        }
    }








32.6.OleDbConnection
32.6.1.Output properties for OleDbConnection
32.6.2.OleDbConnection connection state
32.6.3.Connection Pooling Sample
32.6.4.Connecting to an OLE DB Data Source
32.6.5.Connection for OleDb
32.6.6.Retrieving Data from a Text File
32.6.7.Connect to SqlServer using OleDbConnection
32.6.8.Retrieves a list of tables in a database
32.6.9.Reading Access Data with OleDbConnection