Querying with the DataAdapter
The CData ADO.NET Provider for Confluence implements two ADO.NET interfaces you can use to retrieve data from Confluence: ConfluenceDataAdapter and ConfluenceDataReader objects. Whereas ConfluenceDataAdapter objects retrieve a single result set of all the data that matches a query, ConfluenceDataReader objects fetch data in subset increments as needed.
Using the ConfluenceDataAdapter
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 ConfluenceDataAdapter is slower than the ConfluenceDataReader because the Fill method needs to retrieve all data from the data source before returning.
The following example selects the Key and Name columns of the Pages table:
C#
string connectionString = "User=admin;APIToken=myApiToken;Url=https://yoursitename.atlassian.net;Timezone=America/New_York;"; using (ConfluenceConnection connection = new ConfluenceConnection(connectionString)) { ConfluenceDataAdapter dataAdapter = new ConfluenceDataAdapter( "SELECT Key, Name FROM Pages", connection); DataTable table = new DataTable(); dataAdapter.Fill(table); Console.WriteLine("Contents of Pages."); foreach (DataRow row in table.Rows) { Console.WriteLine("{0}: {1}", row["Key"], row["Name"]); } }
VB.NET
Dim connectionString As String = "User=admin;APIToken=myApiToken;Url=https://yoursitename.atlassian.net;Timezone=America/New_York;" Using connection As New ConfluenceConnection(connectionString) Dim dataAdapter As New ConfluenceDataAdapter("SELECT Key, Name FROM Pages", connection) Dim table As New DataTable() dataAdapter.Fill(table) Console.WriteLine("Contents of Pages.") For Each row As DataRow In table.Rows Console.WriteLine("{0}: {1}", row("Key"), row("Name")) Next End Using