Querying with the DataAdapter
The CData ADO.NET Provider for SAP Concur implements two ADO.NET interfaces you can use to retrieve data from SAP Concur: SAPConcurDataAdapter and SAPConcurDataReader objects. Whereas SAPConcurDataAdapter objects retrieve a single result set of all the data that matches a query, SAPConcurDataReader objects fetch data in subset increments as needed.
Using the SAPConcurDataAdapter
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 SAPConcurDataAdapter is slower than the SAPConcurDataReader because the Fill method needs to retrieve all data from the data source before returning.
The following example selects the Id and OfficeId columns of the Departments table:
C#
string connectionString = "InitiateOAuth=GETANDREFRESH;OAuthClientId=MyOAuthClientId;OAuthClientSecret=MyOAuthClientSecret;"; using (SAPConcurConnection connection = new SAPConcurConnection(connectionString)) { SAPConcurDataAdapter dataAdapter = new SAPConcurDataAdapter( "SELECT Id, OfficeId FROM Departments", connection); DataTable table = new DataTable(); dataAdapter.Fill(table); Console.WriteLine("Contents of Departments."); foreach (DataRow row in table.Rows) { Console.WriteLine("{0}: {1}", row["Id"], row["OfficeId"]); } }
VB.NET
Dim connectionString As String = "InitiateOAuth=GETANDREFRESH;OAuthClientId=MyOAuthClientId;OAuthClientSecret=MyOAuthClientSecret;" Using connection As New SAPConcurConnection(connectionString) Dim dataAdapter As New SAPConcurDataAdapter("SELECT Id, OfficeId FROM Departments", connection) Dim table As New DataTable() dataAdapter.Fill(table) Console.WriteLine("Contents of Departments.") For Each row As DataRow In table.Rows Console.WriteLine("{0}: {1}", row("Id"), row("OfficeId")) Next End Using