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 |