System.Data.DataSet の変更内容を、関連するデータベース内のデータに一致させる単一テーブルのコマンドを、自動的に生成します。
Visual Basic Public Class ULCommandBuilder Inherits DbCommandBuilder
C# public class ULCommandBuilder: DbCommandBuilder
ULDataAdapter は、System.Data.DataSet の変更内容を関連するデータ・ソース内のデータに一致させるために必要な SQL 文を、自動的には生成しません。ただし、ULDataAdapter の SelectCommand プロパティを設定すると単一テーブルを更新する SQL 文を自動的に生成するような、ULCommandBuilder オブジェクトを作成することはできます。これにより、設定していない追加の SQL 文が ULCommandBuilder によって生成されます。
継承:System.ComponentModel.Component
実装:System.IDisposable
次の例では、ULCommand を ULDataAdapter と ULConnection とともに使用して、データ・ソースからローを選択します。この例では、接続文字列、クエリ文字列 (SQL SELECT 文)、データベース・テーブル名を表す文字列を受け取り、次に ULCommandBuilder を作成します。
' Visual Basic Public Shared Function SelectULRows(ByVal connectionString As String, _ ByVal queryString As String, ByVal tableName As String) Dim connection As ULConnection = New ULConnection(connectionString) Dim adapter As ULDataAdapter = New ULDataAdapter() adapter.SelectCommand = New ULCommand(queryString, connection) Dim builder As ULCommandBuilder = New ULCommandBuilder(adapter) connection.Open() Dim dataSet As DataSet = New DataSet() adapter.Fill(dataSet, tableName) 'code to modify data in DataSet here 'Without the ULCommandBuilder this line would fail adapter.Update(dataSet, tableName) Return dataSet End Function // C# public static DataSet SelectULRows(string connectionString, string queryString, string tableName) { using (ULConnection connection = new ULConnection(connectionString)) { ULDataAdapter adapter = new ULDataAdapter(); adapter.SelectCommand = new ULCommand(queryString, connection); ULCommandBuilder builder = new ULCommandBuilder(adapter); connection.Open(); DataSet dataSet = new DataSet(); adapter.Fill(dataSet, tableName); //code to modify data in DataSet here //Without the ULCommandBuilder this line would fail adapter.Update(dataSet, tableName); return dataSet; } } |
ULCommandBuilder メンバ
ULCommandBuilder コンストラクタ
DataAdapter プロパティ
GetDeleteCommand メソッド
GetInsertCommand メソッド
GetUpdateCommand メソッド
Copyright © 2009, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.1 |