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