using System;
using System.Data;
using System.Data.OracleClient;
class OracleConnect
{
static void Main()
{
string connString = @"server = myServer;uid = scott;password = tiger;";
OracleConnection conn = new OracleConnection(connString);
try
{
conn.Open();
Console.WriteLine("Connection opened.");
Console.WriteLine("Connection Properties:");
Console.WriteLine("\tConnection String: {0}", conn.ConnectionString);
Console.WriteLine("\tServerVersion: {0}", conn.ServerVersion);
Console.WriteLine("\tState: {0}", conn.State);
} catch (OracleException e) {
Console.WriteLine("Error: " + e);
} finally {
conn.Close();
Console.WriteLine("Connection closed.");
}
}
}
|