using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.OleDb;
namespace ConnectionOledb
{
class Program
{
static void Main(string[] args)
{
OleDbConnection conn = new OleDbConnection(@"
provider=sqloledb;
data source=.;
integrated security =sspi;
");
try
{
conn.Open();
Console.WriteLine("Connection opened.");
Console.WriteLine("Connection Properties:");
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 close.");
}
Console.ReadKey();
}
}
}