OdbcDataAdapter.DeleteCommand プロパティ
アセンブリ: System.Data (system.data.dll 内)

Dim instance As OdbcDataAdapter Dim value As OdbcCommand value = instance.DeleteCommand instance.DeleteCommand = value
/** @property */ public OdbcCommand get_DeleteCommand () /** @property */ public void set_DeleteCommand (OdbcCommand value)
public function get DeleteCommand () : OdbcCommand public function set DeleteCommand (value : OdbcCommand)
更新操作で、DataSet 内の削除行に対応するデータ ソース内のレコードを削除するための OdbcCommand。

作成済みの OdbcCommand に DeleteCommand プロパティが割り当てられた場合、OdbcCommand のクローンは作成されません。代わりに、DeleteCommand によって、作成済みの OdbcCommand への参照が維持されます。
更新操作では、DeleteCommand が設定されておらず、DataSet に主キー情報が存在する場合、OdbcCommandBuilder クラスを使用して、DeleteCommand、およびデータ ソースと DataSet 間の調整に使用する追加コマンドを自動生成できます。これを行うには、OdbcDataAdapter の SelectCommand プロパティを設定する必要があります。この生成ロジックでは、DataSet 内にキー列情報が存在している必要があります。詳細については、「コマンドの自動生成」を参照してください。

OdbcDataAdapter を作成して SelectCommand プロパティと DeleteCommand プロパティを設定する例を次に示します。ここでは、OdbcConnection オブジェクトが既に作成されていることを前提にしています。
Public Function CreateDataAdapter( _ ByVal connection As OdbcConnection) As OdbcDataAdapter Dim selectCommand As String = _ "SELECT CustomerID, CompanyName FROM Customers" Dim adapter As OdbcDataAdapter = _ New OdbcDataAdapter(selectCommand, connection) adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey ' Create the Insert, Update and Delete commands. adapter.InsertCommand = New OdbcCommand( _ "INSERT INTO Customers (CustomerID, CompanyName) " & _ "VALUES (?, ?)") adapter.UpdateCommand = New OdbcCommand( _ "UPDATE Customers SET CustomerID = ?, CompanyName = ? " & _ "WHERE CustomerID = ?") adapter.DeleteCommand = New OdbcCommand( _ "DELETE FROM Customers WHERE CustomerID = ?") ' Create the parameters. adapter.InsertCommand.Parameters.Add( _ "@CustomerID", OdbcType.Char, 5, "CustomerID") adapter.InsertCommand.Parameters.Add( _ "@CompanyName", OdbcType.VarChar, 40, "CompanyName") adapter.UpdateCommand.Parameters.Add( _ "@CustomerID", OdbcType.Char, 5, "CustomerID") adapter.UpdateCommand.Parameters.Add( _ "@CompanyName", OdbcType.VarChar, 40, "CompanyName") adapter.UpdateCommand.Parameters.Add( _ "@oldCustomerID", OdbcType.Char, 5, "CustomerID").SourceVersion = _ DataRowVersion.Original adapter.DeleteCommand.Parameters.Add( _ "@CustomerID", OdbcType.Char, 5, "CustomerID").SourceVersion = _ DataRowVersion.Original Return adapter End Function
public static OdbcDataAdapter CreateDataAdapter( OdbcConnection connection) { string selectCommand = "SELECT CustomerID, CompanyName FROM Customers"; OdbcDataAdapter adapter = new OdbcDataAdapter( selectCommand, connection); adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey; // Create the Insert, Update and Delete commands. adapter.InsertCommand = new OdbcCommand( "INSERT INTO Customers (CustomerID, CompanyName) " + "VALUES (?, ?)"); adapter.UpdateCommand = new OdbcCommand( "UPDATE Customers SET CustomerID = ?, CompanyName = ? " + "WHERE CustomerID = ?"); adapter.DeleteCommand = new OdbcCommand( "DELETE FROM Customers WHERE CustomerID = ?"); // Create the parameters. adapter.InsertCommand.Parameters.Add("@CustomerID", OdbcType.Char, 5, "CustomerID"); adapter.InsertCommand.Parameters.Add("@CompanyName", OdbcType.VarChar, 40, "CompanyName"); adapter.UpdateCommand.Parameters.Add("@CustomerID", OdbcType.Char, 5, "CustomerID"); adapter.UpdateCommand.Parameters.Add("@CompanyName", OdbcType.VarChar, 40, "CompanyName"); adapter.UpdateCommand.Parameters.Add("@oldCustomerID", OdbcType.Char, 5, "CustomerID").SourceVersion = DataRowVersion.Original; adapter.DeleteCommand.Parameters.Add("@CustomerID", OdbcType.Char, 5, "CustomerID").SourceVersion = DataRowVersion.Original; return adapter; }

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からOdbcDataAdapter.DeleteCommand プロパティを検索する場合は、下記のリンクをクリックしてください。

- OdbcDataAdapter.DeleteCommand プロパティのページへのリンク