QuickBooksDataReader Class
Reads a forward-only stream of rows from QuickBooks Online.
The following example creates a
QuickBooksConnection, a
QuickBooksCommand, and a
QuickBooksDataReader. The example reads through the data, writing it out to the console. Finally, the example closes the
QuickBooksDataReader, then the
QuickBooksConnection.
public void ReadMyData(string myConnString) {
QuickBooksConnection quickBooksConnection = new QuickBooksConnection(myConnString);
QuickBooksCommand quickBooksCommand = (QuickBooksCommand)quickBooksConnection.CreateCommand();
quickBooksCommand.CommandText = "SELECT Id, DisplayName, Notes FROM Customer";
quickBooksConnection.Open();
QuickBooksDataReader quickBooksReader = quickBooksCommand.ExecuteReader();
try {
// Always call Read before accessing data.
while (quickBooksReader.Read()) {
Console.WriteLine(quickBooksReader.GetString(0) + " " +
quickBooksReader.GetString(1) + " " + quickBooksReader.GetString(2));
}
}
finally {
// always call Close when done reading.
quickBooksReader.Close();
// Close the connection when done with it.
quickBooksConnection.Close();
}
}
Public Sub ReadMyData(ByVal myConnString As String)
Dim quickBooksConnection As New QuickBooksConnection(myConnString)
Dim quickBooksCommand As QuickBooksCommand = quickBooksConnection.CreateCommand()
quickBooksCommand.CommandText = "SELECT Id, DisplayName, Notes FROM Customer"
quickBooksConnection.Open()
Dim quickBooksReader As QuickBooksDataReader = quickBooksCommand.ExecuteReader()
Try
' Always call Read before accessing data.
While quickBooksReader.Read()
Console.WriteLine(String.Concat(quickBooksReader.GetString(0), " ", _
quickBooksReader.GetString(1), " ", quickBooksReader.GetString(2)))
End While
Finally
' always call Close when done reading.
quickBooksReader.Close()
' Close the connection when done with it.
quickBooksConnection.Close()
End Try
End Sub