class Program
{
private static string connStr = "User Id=用户名;Password=密码;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=Orale服务器IP地址)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=服务名)))";
static void Main(string[] args)
{
using (var oracleConnection = new OracleConnection(connStr))
{
try
{
oracleConnection.Open();
Console.WriteLine("打开成功!");
}
catch(Exception ex)
{
Console.WriteLine("打开失败!");
Console.WriteLine(ex.Message);
}
finally
{
oracleConnection.Close();
}
}
Console.ReadLine();
}
}