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