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