Firebird ADO.NET Provider SDK Documentation - v1.7

FbDataReader Class

Provides a Way for reading a forward-only stream of rows. This class cannot be inherited.

For a list of all members of this type, see FbDataReader Members.

System.Object
   System.MarshalByRefObject
      FirebirdSql.Data.Firebird.FbDataReader

[Visual Basic]
<DefaultMember(MemberName:="Item")>
NotInheritable Public Class FbDataReader
    Inherits MarshalByRefObject
    Implements IDataReader, IDisposable, IDataRecord, IEnumerable
[C#]
[DefaultMember(MemberName="Item")]
public sealed class FbDataReader : MarshalByRefObject, IDataReader, IDisposable, IDataRecord, IEnumerable

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Remarks

This class cannot be instatiated directly, to create a FbDataReader, you need to call the ExecuteReader method of a FbCommand object.

Until the FbDataReader is closed using the Close method of of the FbDataReader, the associated FbConnection is busy busy serving the FbDataReader, and no other operations can be performed on the FbConnection other than closing it. This is the case until the Close method is called.

To retrieve output parameters you must close the FbDataReader.

IsClosed and RecordsAffected are the only properties that you can call after the FbDataReader is closed.

Example

public void ReadMyData(string myConnString) 
{
    string mySelectQuery = "SELECT dept_no, departament FROM departament";
    
    FbConnection    myConnection = new FblConnection(myConnString);
    myConnection.Open();
    
    FbTransaction    myTxn         = myConnection.BeginTransaction();
    FbCommand        myCommand    = new FbCommand(mySelectQuery, myConnection, myTxn);
            
    FbDataReader myReader;
    myReader = myCommand.ExecuteReader();
    
    // Always call Read before accessing data.
    while (myReader.Read()) 
    {
    Console.WriteLine(myReader.GetInt32(0) + ", " + myReader.GetString(1));
    }
    
    // always call Close when done reading.
    myReader.Close();
    
    // Close the connection when done with it.
    myConnection.Close();
}    
                

Requirements

Namespace: FirebirdSql.Data.Firebird

Assembly: FirebirdSql.Data.Firebird (in FirebirdSql.Data.Firebird.dll)

See Also

FbDataReader Members | FirebirdSql.Data.Firebird Namespace