dotConnect for FreshBooks Documentation
Devart.Data.FreshBooks Namespace / FreshBooksDataReader Class
Members Example

FreshBooksDataReader Class
Reads a forward-only stream of rows from FreshBooks.
Syntax
Remarks
To create a FreshBooksDataReader, you must call the ExecuteReader method of the FreshBooksCommand object, rather than directly using a constructor.

System.Data.Common.DbDataReader.IsClosed and Devart.Data.SqlShimDataReader.RecordsAffected are the only properties that you can call after the FreshBooksDataReader is closed. In some cases, you must call Devart.Data.SqlShimDataReader.Close before you can call Devart.Data.SqlShimDataReader.RecordsAffected.

Example
The following example creates a FreshBooksConnection, a FreshBooksCommand, and a FreshBooksDataReader. The example reads through the data, writing it out to the console. Finally, the example closes the FreshBooksDataReader, then the FreshBooksConnection.
public void ReadMyData(string myConnString)  {
        FreshBooksConnection freshbooksConnection = new FreshBooksConnection(myConnString);
        FreshBooksCommand freshbooksCommand = (FreshBooksCommand)freshbooksConnection.CreateCommand();
        freshbooksCommand.CommandText = "SELECT Id, FirstName, LastName FROM Client";
        freshbooksConnection.Open();
        FreshBooksDataReader freshbooksReader = freshbooksCommand.ExecuteReader();
        try {
                // Always call Read before accessing data.
                while (freshbooksReader.Read()) {
                Console.WriteLine(freshbooksReader.GetString(0) + " " + 
                freshbooksReader.GetString(1) + " " + freshbooksReader.GetString(2));
        }
        }
        finally {
                // always call Close when done reading.
                freshbooksReader.Close();

                // Close the connection when done with it.
                freshbooksConnection.Close();
        }
}
Public Sub ReadMyData(ByVal myConnString As String)
        Dim freshbooksConnection As New FreshBooksConnection(myConnString)
        Dim freshbooksCommand As FreshBooksCommand = freshbooksConnection.CreateCommand()
                freshbooksCommand.CommandText = "SELECT Id, FirstName, LastName FROM Client"
        freshbooksConnection.Open()
        Dim freshbooksReader As FreshBooksDataReader = freshbooksCommand.ExecuteReader()
        Try
                ' Always call Read before accessing data.
                While freshbooksReader.Read()
                        Console.WriteLine(String.Concat(freshbooksReader.GetString(0), " ", _
                        freshbooksReader.GetString(1), " ", freshbooksReader.GetString(2)))
                End While
        Finally
                ' always call Close when done reading.
                freshbooksReader.Close()

                        ' Close the connection when done with it.
                        freshbooksConnection.Close()
        End Try
End Sub
Inheritance Hierarchy

System.Object
   System.MarshalByRefObject
      System.Data.Common.DbDataReader
         Devart.Common.DbDataReaderBase
            Devart.Data.SqlShimDataReader
               Devart.Data.FreshBooks.FreshBooksDataReader

Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also