クライアントインターフェイスガイド > TDV用TIBCO ADO .NET 2020データプロバイダー > ADO.NET(DbProviderFactory)の使用 > DbCommandの実行
 
DbCommandsの実行
次のセクションでは、DbCommandやDbDataAdapterなどのADO.NET基本クラスを使用してコマンドを実行する方法を示します。
TDVへのコマンドの実行
次のコードは、既存のDbConnectionオブジェクトを指定して、TDVに対して「SELECT *」クエリを実行します。
 
using (connection) {
// Create the DbCommand.
DbCommand command = factory.CreateCommand();
command.CommandText =
"SELECT * FROM Products";
command.Connection = connection;
// Create the DbDataAdapter.
DbDataAdapter adapter = factory.CreateDataAdapter();
adapter.SelectCommand = command;
// Fill the DataTable.
DataTable table = new DataTable();
adapter.Fill(table);
// Display each row and column value.
foreach (DataRow row in table.Rows) {
foreach (DataColumn column in table.Columns) {
Console.WriteLine(row[column]);
}
}
}