Querying with the DataAdapter
The ADO.NET Provider for TIBCO(R) Data Virtualization implements two ADO.NET interfaces you can use to retrieve data from TDV: CompositeDataAdapter and CompositeDataReader objects. Whereas CompositeDataAdapter objects retrieve a single result set of all the data that matches a query, CompositeDataReader objects fetch data in subset increments as needed.
Using the CompositeDataAdapter
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 thequeried data. Note that the CompositeDataAdapter is slower than the CompositeDataReader because the Fill method needs to retrieve all data from the data source before returning.
The following example selects the Id and ProductName columns of the Products table:
C#
string connectionString = "Host=myHost;Domain=myDomain;DataSource=myDataSource;User=myUser;Password=myPassword";
using (CompositeConnection connection = new CompositeConnection(connectionString)) {CompositeDataAdapter dataAdapter = new CompositeDataAdapter(
"SELECT Id, ProductName FROM [Public].[Sample].Products", connection);
DataTable table = new DataTable();
dataAdapter.Fill(table);
Console.WriteLine("Contents of Products."); foreach (DataRow row in table.Rows) { Console.WriteLine("{0}: {1}", row["Id"], row["ProductName"]);}
}
VB.NET
Dim connectionString As String = "Host=myHost;Domain=myDomain;DataSource=myDataSource;User=myUser;Password=myPassword"
Using connection As New CompositeConnection(connectionString)
Dim dataAdapter As New CompositeDataAdapter("SELECT Id, ProductName FROM [Public].[Sample].Products", connection)Dim table As New DataTable()
dataAdapter.Fill(table)
Console.WriteLine("Contents of Products.")For Each row As DataRow In table.Rows
Console.WriteLine("{0}: {1}", row("Id"), row("ProductName"))Next
End Using