c#连接oracle数据库
连接字符串
public static string connString = "User ID=DatabaseName;Password=OraclePwd;Data Source=(DESCRIPTION = (ADDRESS_LIST= (ADDRESS = (PROTOCOL = TCP)(HOST = IPAddress)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = orcl)))";
引用命名空间
using Oracle.ManagedDataAccess.Client;
连接方法
public int GetConn()
{
OracleConnection conn = new OracleConnection(connString);
int result = 0;
try
{
conn.Open();
result = 1;
}
catch (Exception ex)
{
throw (ex);
}
finally
{
conn.Close();
}
return result;
}
在其他地方就可以调用这个方法使用了