# 刪除 DataRowDataRow Deletion

DataSet當使用或DataTable搭配DataAdapter和關聯式資料來源時，請使用DataRowDelete方法來移除資料列。When using a DataSet or DataTable in conjunction with a DataAdapter and a relational data source, use the Delete method of the DataRow to remove the row. Delete方法會將資料列標示為已在DataSetDataTable刪除，但不會將它移除。The Delete method marks the row as Deleted in the DataSet or DataTable but does not remove it. 相反地，當DataAdapter遇到標記為已刪除的資料列時，它會執行其DeleteCommand方法，以刪除資料來源中的資料列。Instead, when the DataAdapter encounters a row marked as Deleted, it executes its DeleteCommand method to delete the row at the data source. 然後，您可以使用AcceptChanges方法來永久移除該資料列。The row can then be permanently removed using the AcceptChanges method. 如果您使用 [移除] 來刪除資料列，就會從資料表中移除該資料列，但DataAdapter不會刪除資料來源中的資料列。If you use Remove to delete the row, the row is removed entirely from the table, but the DataAdapter will not delete the row at the data source.

DataRowCollectionRemove方法會採用DataRow做為引數，並將它從集合中移除，如下列範例所示。The Remove method of the DataRowCollection takes a DataRow as an argument and removes it from the collection, as shown in the following example.

workTable.Rows.Remove(workRow)

workTable.Rows.Remove(workRow);


workRow.Delete

workRow.Delete();