ADO.NET Provider for Adobe Commerce

Build 23.0.8839

Querying with the DataAdapter

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

Using the AdobeCommerceDataAdapter

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

The following example selects the Price and Name columns of the Products table:

C#

string connectionString = "User=admin;Password=admin;Url=https://myadobecommercehost";

using (AdobeCommerceConnection connection = new AdobeCommerceConnection(connectionString)) {
  AdobeCommerceDataAdapter dataAdapter = new AdobeCommerceDataAdapter(
  "SELECT Price, Name FROM Products", connection);

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

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

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

VB.NET

Dim connectionString As String = "User=admin;Password=admin;Url=https://myadobecommercehost"

Using connection As New AdobeCommerceConnection(connectionString)
  Dim dataAdapter As New AdobeCommerceDataAdapter("SELECT Price, Name FROM Products", connection)

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

  Console.WriteLine("Contents of Products.")

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

Copyright (c) 2024 CData Software, Inc. - All rights reserved.
Build 23.0.8839