ADO.NET Provider for Zoho Books

Build 22.0.8462

Querying with the DataAdapter

The CData ADO.NET Provider for Zoho Books implements two ADO.NET interfaces you can use to retrieve data from Zoho Books: ZohoBooksDataAdapter and ZohoBooksDataReader objects. Whereas ZohoBooksDataAdapter objects retrieve a single result set of all the data that matches a query, ZohoBooksDataReader objects fetch data in subset increments as needed.

Using the ZohoBooksDataAdapter

Use the adapter's Fill method to retrieve data from the data source. An empty DataTable instance is passed as an argument to the Fill method. When the method returns, the DataTable instance is populated with the queried data. Note that the ZohoBooksDataAdapter is slower than the ZohoBooksDataReader because the Fill method needs to retrieve all data from the data source before returning.

The following example selects the InvoiceId and InvoiceNumber columns of the INVOICES table:

C#

string connectionString = "InitiateOAuth=GETANDREFRESH;OrganizationId=YourOrganizationId;AccountsServer=YourAccountServerURL";

using (ZohoBooksConnection connection = new ZohoBooksConnection(connectionString)) {
  ZohoBooksDataAdapter dataAdapter = new ZohoBooksDataAdapter(
  "SELECT InvoiceId, InvoiceNumber FROM INVOICES", connection);

  DataTable table = new DataTable();
  dataAdapter.Fill(table);

  Console.WriteLine("Contents of INVOICES.");

  foreach (DataRow row in table.Rows) {
    Console.WriteLine("{0}: {1}", row["InvoiceId"], row["InvoiceNumber"]);
  }
}

VB.NET

Dim connectionString As String = "InitiateOAuth=GETANDREFRESH;OrganizationId=YourOrganizationId;AccountsServer=YourAccountServerURL"

Using connection As New ZohoBooksConnection(connectionString)
  Dim dataAdapter As New ZohoBooksDataAdapter("SELECT InvoiceId, InvoiceNumber FROM INVOICES", connection)

  Dim table As New DataTable()
  dataAdapter.Fill(table)

  Console.WriteLine("Contents of INVOICES.")

  For Each row As DataRow In table.Rows
    Console.WriteLine("{0}: {1}", row("InvoiceId"), row("InvoiceNumber"))
  Next
End Using

Copyright (c) 2023 CData Software, Inc. - All rights reserved.
Build 22.0.8462