Querying with the DataAdapter
The CData ADO.NET Provider for TaxJar implements two ADO.NET interfaces you can use to retrieve data from TaxJar: TaxJarDataAdapter and TaxJarDataReader objects. Whereas TaxJarDataAdapter objects retrieve a single result set of all the data that matches a query, TaxJarDataReader objects fetch data in subset increments as needed.
Using the TaxJarDataAdapter
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 TaxJarDataAdapter is slower than the TaxJarDataReader because the Fill method needs to retrieve all data from the data source before returning.
The following example selects the TransactionID and UserID columns of the Orders table:
C#
string connectionString = "APIKey=3bb04218ef8t80efdf1739abf7257144;"; using (TaxJarConnection connection = new TaxJarConnection(connectionString)) { TaxJarDataAdapter dataAdapter = new TaxJarDataAdapter( "SELECT TransactionID, UserID 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["TransactionID"], row["UserID"]); } }
VB.NET
Dim connectionString As String = "APIKey=3bb04218ef8t80efdf1739abf7257144;" Using connection As New TaxJarConnection(connectionString) Dim dataAdapter As New TaxJarDataAdapter("SELECT TransactionID, UserID 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("TransactionID"), row("UserID")) Next End Using