ADO.NET Provider for Sage 200

Build 24.0.8963

Querying with the DataAdapter

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

Using the Sage200DataAdapter

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

The following example selects the Id and Code columns of the Banks table:

C#

string connectionString = "InitiateOAuth=GETANDREFRESH;SubscriptionKey=12345;Schema=StandardUK";

using (Sage200Connection connection = new Sage200Connection(connectionString)) {
  Sage200DataAdapter dataAdapter = new Sage200DataAdapter(
  "SELECT Id, Code FROM Banks", connection);

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

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

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

VB.NET

Dim connectionString As String = "InitiateOAuth=GETANDREFRESH;SubscriptionKey=12345;Schema=StandardUK"

Using connection As New Sage200Connection(connectionString)
  Dim dataAdapter As New Sage200DataAdapter("SELECT Id, Code FROM Banks", connection)

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

  Console.WriteLine("Contents of Banks.")

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

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