Represents a SQL statement or stored procedure to execute against Zoho Desk.
The following example uses the
ExecuteReader method of
ZohoDeskCommand, along with
ZohoDeskDataReader and
ZohoDeskConnection, to select rows from a table.
|
|---|
public void ReadMyData(string myConnString)
{
string mySelectQuery = "SELECT AccountID, \"Account Name\" FROM Accounts";
ZohoDeskConnection zohoDeskConnection = new ZohoDeskConnection(myConnString);
ZohoDeskCommand zohoDeskCommand = new ZohoDeskCommand(mySelectQuery,zohoDeskConnection);
zohoDeskConnection.Open();
ZohoDeskDataReader zohoDeskReader = zohoDeskCommand.ExecuteReader();
try
{
while (zohoDeskReader.Read())
{
Console.WriteLine(zohoDeskReader.GetString(0) + ", " + zohoDeskReader.GetString(1));
}
}
finally
{
// always call Close when done reading.
zohoDeskReader.Close();
// always call Close when done reading.
zohoDeskConnection.Close();
}
} |
|
|---|
Public Sub ReadMyData(myConnString As String)
Dim mySelectQuery As String = "SELECT AccountID, \"Account Name\" FROM Accounts"
Dim zohoDeskConnection As New ZohoDeskConnection(myConnString)
Dim zohoDeskCommand As New ZohoDeskCommand(mySelectQuery, zohoDeskConnection)
zohoDeskConnection.Open()
Dim zohoDeskReader As ZohoDeskDataReader = zohoDeskCommand.ExecuteReader()
Try
While zohoDeskReader.Read()
Console.WriteLine(zohoDeskReader.GetString(0) + ", " _
+ zohoDeskReader.GetString(1))
End While
Finally
' always call Close when done reading.
zohoDeskReader.Close()
' always call Close when done with connection.
zohoDeskConnection.Close()
End Try
End Sub |