public OracleConnection GetConnection_Oracle()
{
string connStr = "Data Source=(DESCRIPTION=(ADDRESS_LIST="
+ "(ADDRESS=(PROTOCOL=TCP)(HOST=Server IP Address)(PORT=Server Port Number)))"
+ "(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=etds)(INSTANCE_NAME=etds)));"
+ "User Id=redfd;Password=dfdf;";
OracleConnection conn = new OracleConnection(connStr);
return conn;
}
public DataTable GetDataTable_Oracle(string query, out string ERROR)
{
OracleConnection dbCon = GetConnection_Oracle();
dbCon.Open();
DataTable dt = new DataTable();
OracleCommand command = new OracleCommand();
command.Connection = dbCon;
command.CommandType = CommandType.Text;
command.CommandText = query;
command.CommandTimeout = 300;
try
{
OracleDataReader dr = command.ExecuteReader();
ERROR = String.Empty;
dt.Load(dr);
}
catch (Exception ex)
{
//ERROR = ex.ToString();
ERROR = "";
}
finally
{
dbCon.Close();
}
return dt;
}
{
string connStr = "Data Source=(DESCRIPTION=(ADDRESS_LIST="
+ "(ADDRESS=(PROTOCOL=TCP)(HOST=Server IP Address)(PORT=Server Port Number)))"
+ "(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=etds)(INSTANCE_NAME=etds)));"
+ "User Id=redfd;Password=dfdf;";
OracleConnection conn = new OracleConnection(connStr);
return conn;
}
public DataTable GetDataTable_Oracle(string query, out string ERROR)
{
OracleConnection dbCon = GetConnection_Oracle();
dbCon.Open();
DataTable dt = new DataTable();
OracleCommand command = new OracleCommand();
command.Connection = dbCon;
command.CommandType = CommandType.Text;
command.CommandText = query;
command.CommandTimeout = 300;
try
{
OracleDataReader dr = command.ExecuteReader();
ERROR = String.Empty;
dt.Load(dr);
}
catch (Exception ex)
{
//ERROR = ex.ToString();
ERROR = "";
}
finally
{
dbCon.Close();
}
return dt;
}
No comments:
Post a Comment