<connectionStrings>
<add name="oracle" connectionString="Data Source= (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = xxx.xxx.xxx.xxx)(PORT = xxxx))) (CONNECT_DATA = (SERVICE_NAME= xxxx) ));User ID=xxxx;Password=xxxx" providerName="System.Data.OracleClient" />
</connectionStrings>
HOST = xxx.xxx.xxx.xxx为IP地址
PORT = xxxx为端口
SERVICE_NAME= xxxx为数据库名
User ID=xxxx;Password=xxxx为数据库用户名和密码
using Oracle.ManagedDataAccess.Client;
/// <summary>
/// 传入ORACLE-SQL获取SqlDataReader
/// </summary>
/// <param name="sql"></param>
/// <returns>OracleDataReader</returns>
public static OracleDataReader GetOracleReader(string sqlconn, string sql)
{
OracleConnection conn = new OracleConnection(sqlconn);
conn.Open();
OracleCommand cmd = new OracleCommand(sql, conn);
OracleDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
return reader;
}