I'm new in ODP.Net and trying to implement it to our existing system. Currently, we are using OLEDB and using IDataReader interface to read a record from DataReader. However, when we use ODP.Net using the same code logic, no records selected. So, my question is, does Oracle.DataAccess.Client.OracleDataReader (ODP.Net) implements IDataReader interface? If i try read the record using OracleDataReader without using IDataReader the record selected.
I'm using ODP.Net 10.1.0.4, Oracle Client 10g, ASP.Net
Edit:
string lstSelect = fstSelect + pstWhereClause;
IDbConnection lidcConn = fobCreateCon.CreateConnection();
lidcConn.ConnectionString = fstConStr;
IDbCommand lidcComm = fobCreateCon.CreateCommand();
lidcComm.Connection = lidcConn;
lidcComm.CommandText = lstSelect;
if (palParams != null)
{
for (int i = 0; i < palParams.Length; i++)
{
IDbDataParameter lidpParam = fobCreateCon.CreateParameter(
fstParameterPrefix + "PARA" + i.ToString(), palParams[i]);
lidcComm.Parameters.Add(lidpParam);
}
}
IDataReader lidrReader = null;
try
{
lidcConn.Open();
lidrReader = lidcComm.ExecuteReader(CommandBehavior.CloseConnection);
bool lboReturn = lidrReader.Read();
if (lboReturn)
{
fobEmployee.AR_Grace = lidrReader.IsDBNull(0) ? 0 : lidrReader.GetDecimal(0);
fobEmployee.Card_Issued = lidrReader.IsDBNull(1) ? string.Empty : lidrReader.GetString(1);
}
lidrReader.Close();
return lboReturn;
}
finally
{
if (lidrReader != null)
{
if (!lidrReader.IsClosed)
lidrReader.Close();
lidrReader.Dispose();
}
if (lidcConn.State != ConnectionState.Closed)
lidcConn.Close();
lidcConn.Dispose();
lidcComm.Dispose();
}
Above is the code we using right now. It works perfectly with OLEDB, SQLClient. Somehow no record return when using this code with ODP.Net.
We manage to select the record when change to this
OracleDataReader lidrReader = null;
try
{
lidcConn.Open();
lidrReader = (OracleDataReader)lidcComm.ExecuteReader(CommandBehavior.CloseConnection);
if (lidrReader.HasRow)
{
lidrReader.Read();
fobEmployee.AR_Grace = lidrReader.IsDBNull(0) ? 0 : lidrReader.GetDecimal(0);
fobEmployee.Card_Issued = lidrReader.IsDBNull(1) ? string.Empty : lidrReader.GetString(1);
}
lidrReader.Close();
}
We impossible to change it to the above code cause it will involve more than 300 data file classes and we want this code working for other databases. Any help?