ZohoBooksDataReader Class
Reads a forward-only stream of rows from Zoho Books.
The following example creates a
ZohoBooksConnection, a
ZohoBooksCommand, and a
ZohoBooksDataReader. The example reads through the data, writing it out to the console. Finally, the example closes the
ZohoBooksDataReader, then the
ZohoBooksConnection.
|
|---|
public void ReadMyData(string myConnString) {
ZohoBooksConnection ZohoBooksConnection = new ZohoBooksConnection(myConnString);
ZohoBooksCommand ZohoBooksCommand = (ZohoBooksCommand)ZohoBooksConnection.CreateCommand();
ZohoBooksCommand.CommandText = "SELECT AccountID, \"Account Name\", Phone FROM Accounts";
ZohoBooksConnection.Open();
ZohoBooksDataReader ZohoBooksReader = ZohoBooksCommand.ExecuteReader();
try {
// Always call Read before accessing data.
while (ZohoBooksReader.Read()) {
Console.WriteLine(ZohoBooksReader.GetString(0) + " " +
ZohoBooksReader.GetString(1) + " " + ZohoBooksReader.GetString(2));
}
}
finally {
// always call Close when done reading.
ZohoBooksReader.Close();
// Close the connection when done with it.
ZohoBooksConnection.Close();
}
} |
|
|---|
Public Sub ReadMyData(ByVal myConnString As String)
Dim ZohoBooksConnection As New ZohoBooksConnection(myConnString)
Dim ZohoBooksCommand As ZohoBooksCommand = ZohoBooksConnection.CreateCommand()
ZohoBooksCommand.CommandText = "SELECT AccountID, \"Account Name\", Phone FROM Accounts"
ZohoBooksConnection.Open()
Dim ZohoBooksReader As ZohoBooksDataReader = ZohoBooksCommand.ExecuteReader()
Try
' Always call Read before accessing data.
While ZohoBooksReader.Read()
Console.WriteLine(String.Concat(ZohoBooksReader.GetString(0), " ", _
ZohoBooksReader.GetString(1), " ", ZohoBooksReader.GetString(2)))
End While
Finally
' always call Close when done reading.
ZohoBooksReader.Close()
' Close the connection when done with it.
ZohoBooksConnection.Close()
End Try
End Sub |