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