ExecuteReader(CommandBehavior) Method
The following example creates a
QuickBooksCommand, then executes it by passing a string that is SQL SELECT statement, and a string to use to connect to the data source. The
System.Data.CommandBehavior is then set to CloseConnection.
|
|---|
public void CreateQuickBooksDataReader(string mySelectQuery,string quickBooksConnectionString)
{
QuickBooksConnection quickBooksConnection = new QuickBooksConnection(quickBooksConnectionString);
QuickBooksCommand quickBooksCommand = new QuickBooksCommand(mySelectQuery, quickBooksConnection);
quickBooksCommand.Connection.Open();
QuickBooksDataReader quickBooksReader = quickBooksCommand.ExecuteReader(CommandBehavior.CloseConnection);
while(quickBooksReader.Read())
{
Console.WriteLine(quickBooksReader.GetString(0));
}
quickBooksReader.Close();
} |
|
|---|
Public Sub CreateQuickBooksDataReader(mySelectQuery As String, _
quickBooksConnectionString As String)
Dim quickBooksConnection As New QuickBooksConnection(quickBooksConnectionString)
Dim quickBooksCommand As New QuickBooksCommand(mySelectQuery, quickBooksConnection)
quickBooksCommand.Connection.Open()
Dim quickBooksReader As QuickBooksDataReader = quickBooksCommand.ExecuteReader(CommandBehavior.CloseConnection)
While quickBooksReader.Read()
Console.WriteLine(quickBooksReader.GetString(0))
End While
quickBooksReader.Close()
End Sub |