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