开发者

Does Oracle.DataAccess.Client.OracleDataReader (ODP.Net) implements IDataReader interface?

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 开发者_StackOverflow中文版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?


If we're talking about System.Data.IDataReader, the answer is yes. In fact, OracleDataReader inherits from the abstract class System.Data.Common.DbDataReader which in turn inherits from the System.Data.IDataReader.

In other words, Oracle plays nice with the ADO.NET and should work more or less exactly like the other ADO.NET providers.

I have not tried with the versions prior to 10.2.x though, but I doubt things have changed significantly. I have had no problems with the OracleDataReader.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜