FreshBooksDataReader Class
Reads a forward-only stream of rows from FreshBooks.
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
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