Represents a SQL statement or stored procedure to execute against FreshBooks.
The following example uses the
ExecuteReader method of
FreshBooksCommand, along with
FreshBooksDataReader and
FreshBooksConnection, to select rows from a table.
|
|---|
public void ReadMyData(string myConnString)
{
string mySelectQuery = "SELECT Id, LastName FROM Client";
FreshBooksConnection freshBooksConnection = new FreshBooksConnection(myConnString);
FreshBooksCommand freshBooksCommand = new FreshBooksCommand(mySelectQuery,freshBooksConnection);
freshBooksConnection.Open();
FreshBooksDataReader freshBooksReader = freshBooksCommand.ExecuteReader();
try
{
while (freshBooksReader.Read())
{
Console.WriteLine(freshBooksReader.GetString(0) + ", " + freshBooksReader.GetString(1));
}
}
finally
{
// always call Close when done reading.
freshBooksReader.Close();
// always call Close when done reading.
freshBooksConnection.Close();
}
} |
|
|---|
Public Sub ReadMyData(myConnString As String)
Dim mySelectQuery As String = "SELECT Id, LastName FROM Client"
Dim freshBooksConnection As New FreshBooksConnection(myConnString)
Dim freshBooksCommand As New FreshBooksCommand(mySelectQuery, freshBooksConnection)
freshBooksConnection.Open()
Dim freshBooksReader As FreshBooksDataReader = freshBooksCommand.ExecuteReader()
Try
While freshBooksReader.Read()
Console.WriteLine(freshBooksReader.GetString(0) + ", " _
+ freshBooksReader.GetString(1))
End While
Finally
' always call Close when done reading.
freshBooksReader.Close()
' always call Close when done with connection.
freshBooksConnection.Close()
End Try
End Sub |