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 |