C# 连接Oralce的方法
public class ConnDB
{
OracleConnection conn = null;
//无参数
public OracleConnection getConn()
{
string connString = "Data Source=orcl;User ID=wang;Password=wang";
try
{
conn = new OracleConnection(connString);
}catch(Exception e)
{
Console.WriteLine("{0}second exception caught", e);
Console.WriteLine();
}
return conn;
}
//有参数连接
public OracleConnection getConnByInput(string source, string user, string password)
{
string connString = "Data Source=" + source + ";User ID=" + user + ";Password=" + password;
try
{
conn = new OracleConnection(connString);
}
catch (Exception e)
{
Console.WriteLine("{0}second exception caught", e);
Console.WriteLine();
}
return conn;
}
}