ADO.NET Provider for WooCommerce

Build 20.0.7654

Querying with the DataAdapter

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

Using the WooCommerceDataAdapter

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 WooCommerceDataAdapter is slower than the WooCommerceDataReader because the Fill method needs to retrieve all data from the data source before returning.

The following example selects the ParentId and Total columns of the Orders table:


string connectionString = " Url=http://localhost/wordpress/;ConsumerKey=ck_ec52c76185c088ecaa3145287c8acba55a6f59ad;ConsumerSecret=cs_9fde14bf57126156701a7563fc87575713c355e5;";

using (WooCommerceConnection connection = new WooCommerceConnection(connectionString)) {
  WooCommerceDataAdapter dataAdapter = new WooCommerceDataAdapter(
  "SELECT ParentId, Total FROM Orders", connection);

  DataTable table = new DataTable();

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

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


Dim connectionString As String = " Url=http://localhost/wordpress/;ConsumerKey=ck_ec52c76185c088ecaa3145287c8acba55a6f59ad;ConsumerSecret=cs_9fde14bf57126156701a7563fc87575713c355e5;"

Using connection As New WooCommerceConnection(connectionString)
  Dim dataAdapter As New WooCommerceDataAdapter("SELECT ParentId, Total FROM Orders", connection)

  Dim table As New DataTable()

  Console.WriteLine("Contents of Orders.")

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

Copyright (c) 2020 CData Software, Inc. - All rights reserved.
Build 20.0.7654