Represents a SQL statement or stored procedure to execute against QuickBooks Online.
The following example uses the
ExecuteReader method of
QuickBooksCommand, along with
QuickBooksDataReader and
QuickBooksConnection, to select rows from a table.
public void ReadMyData(string myConnString)
{
string mySelectQuery = "SELECT Id, DisplayName FROM Customer";
QuickBooksConnection quickBooksConnection = new QuickBooksConnection(myConnString);
QuickBooksCommand quickBooksCommand = new QuickBooksCommand(mySelectQuery,quickBooksConnection);
quickBooksConnection.Open();
QuickBooksDataReader quickBooksReader = quickBooksCommand.ExecuteReader();
try
{
while (quickBooksReader.Read())
{
Console.WriteLine(quickBooksReader.GetString(0) + ", " + quickBooksReader.GetString(1));
}
}
finally
{
// always call Close when done reading.
quickBooksReader.Close();
// always call Close when done reading.
quickBooksConnection.Close();
}
}
Public Sub ReadMyData(myConnString As String)
Dim mySelectQuery As String = "SELECT Id, DisplayName FROM Customer"
Dim quickBooksConnection As New QuickBooksConnection(myConnString)
Dim quickBooksCommand As New QuickBooksCommand(mySelectQuery, quickBooksConnection)
quickBooksConnection.Open()
Dim quickBooksReader As QuickBooksDataReader = quickBooksCommand.ExecuteReader()
Try
While quickBooksReader.Read()
Console.WriteLine(quickBooksReader.GetString(0) + ", " _
+ quickBooksReader.GetString(1))
End While
Finally
' always call Close when done reading.
quickBooksReader.Close()
' always call Close when done with connection.
quickBooksConnection.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