Querying with the DataAdapter
The CData ADO.NET Provider for SAP Ariba Procurement implements two ADO.NET interfaces you can use to retrieve data from SAP Ariba: SAPAribaProcurementDataAdapter and SAPAribaProcurementDataReader objects. Whereas SAPAribaProcurementDataAdapter objects retrieve a single result set of all the data that matches a query, SAPAribaProcurementDataReader objects fetch data in subset increments as needed.
Using the SAPAribaProcurementDataAdapter
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 SAPAribaProcurementDataAdapter is slower than the SAPAribaProcurementDataReader because the Fill method needs to retrieve all data from the data source before returning.
The following example selects the DocumentNumber and Revision columns of the Orders table:
C#
string connectionString = "ANID=AN02000000280;API=PurchaseOrdersBuyerAPI-V1;APIKey=wWVLn7WTAXrIRMAzZ6VnuEj7Ekot5jnU;AuthScheme=OAuthClient;InitiateOAuth=GETANDREFRESH;OAuthClientId=testClient;OAuthClientSecret=testClientSecret;UseSandbox=false;"; using (SAPAribaProcurementConnection connection = new SAPAribaProcurementConnection(connectionString)) { SAPAribaProcurementDataAdapter dataAdapter = new SAPAribaProcurementDataAdapter( "SELECT DocumentNumber, Revision FROM Orders", connection); DataTable table = new DataTable(); dataAdapter.Fill(table); Console.WriteLine("Contents of Orders."); foreach (DataRow row in table.Rows) { Console.WriteLine("{0}: {1}", row["DocumentNumber"], row["Revision"]); } }
VB.NET
Dim connectionString As String = "ANID=AN02000000280;API=PurchaseOrdersBuyerAPI-V1;APIKey=wWVLn7WTAXrIRMAzZ6VnuEj7Ekot5jnU;AuthScheme=OAuthClient;InitiateOAuth=GETANDREFRESH;OAuthClientId=testClient;OAuthClientSecret=testClientSecret;UseSandbox=false;" Using connection As New SAPAribaProcurementConnection(connectionString) Dim dataAdapter As New SAPAribaProcurementDataAdapter("SELECT DocumentNumber, Revision FROM Orders", connection) Dim table As New DataTable() dataAdapter.Fill(table) Console.WriteLine("Contents of Orders.") For Each row As DataRow In table.Rows Console.WriteLine("{0}: {1}", row("DocumentNumber"), row("Revision")) Next End Using