DB2 DataAdapter.DeleteCommand 属性

获取或设置用来删除数据库中的记录的 SQL 语句或存储过程。

名称空间:
IBM.Data.DB2
组合件:
IBM.Data.DB2 (在 IBM.Data.DB2.dll)

语法


[Visual Basic]
Public Property DeleteCommand As DB2Command

[C#]
public new DB2Command
 DeleteCommand {get; set;}
[C++]
public: __property DB2Command
* get_DeleteCommand();
public: __property void set_DeleteCommand(DB2Command
*);
[JScript]
public function get DeleteCommand() : DB2Command
;
public function set DeleteCommand(DB2Command
);

属性值

在更新操作期间使用的 DB2® 命令 ,用于删除数据库中与.中已删除行对应的 DataSet记录。

备注

当该 DeleteCommand 属性被赋值给先前创建的 DB2 命令时,该对象不会 DB2Command 被克隆。 相反,该 DeleteCommand 对象保留了对先前创建的对象的 DB2Command引用。

在更新操作过程中, DeleteCommand 若未设置且主键信息存在于表中 DataSet,可使用 DB2 CommandBuilder 类自动生成所需的 DeleteCommand更新语句及额外命令,以将表 DataSet 数据与数据库进行同步。 为此,请设置 DataAdapter DB2 的 属性 SelectCommand。 生成逻辑还要求 DataSet 中存在键列信息。 有关更多信息,请参阅 Microsoft(R) .NET Framework SDK 文档中的“自动生成的命令”。

示例

[Visual Basic, C#] 以下示例创建一个 DB2 数据适配器并设置其部分属性。

[Visual Basic]
Public Sub CreateDB2DataAdapter()
     Dim mySelectText As String = _
       "SELECT * FROM STAFF ORDER BY ID"
     Dim myConnString As String = _
       "DATABASE=SAMPLE;"
     Dim myDataAdapter As New DB2DataAdapter(mySelectText, myConnString)
     Dim myDataAdapter.DeleteCommand = New DB2Command(
       "DELETE FROM STAFF WHERE JOB ='Sales' ", myConnString)
 End Sub

[C#]
public void CreateDB2DataAdapter () {
    string mySelectText = "SELECT * FROM STAFF ORDER BY ID";
    string myConnString = "DATABASE=SAMPLE;";
    DB2DataAdapter myDataAdapter = new DB2DataAdapter(mySelectText,myConnString);
    myDataAdapter.DeleteCommand = New DB2Command(
      "DELETE FROM STAFF WHERE JOB ='Sales' ", myConnString);
 }