DataTable.ImportRow(DataRow) 方法

定義

DataRow 複製至 DataTable,保留任何屬性設定,以及原始值和目前值。

public:
 void ImportRow(System::Data::DataRow ^ row);
public void ImportRow (System.Data.DataRow? row);
public void ImportRow (System.Data.DataRow row);
member this.ImportRow : System.Data.DataRow -> unit
Public Sub ImportRow (row As DataRow)

參數

row
DataRow

要匯入的 DataRow

備註

呼叫 NewRow 會使用現有的資料表架構將資料列新增至資料表,但具有資料列的預設值,並將 設定 DataRowStateDetached 。 呼叫 ImportRow 會保留現有的 DataRowState 和資料列中的其他值。 DataRow如果當做參數傳遞的 處於中斷連結狀態,則會忽略它,而且不會擲回任何例外狀況。

新的資料列將會新增至資料表的結尾。

如果新資料列違反條件約束,則不會新增至資料表。

您可以使用 DataTable.Rows.Find 和 DataTable.Rows.IndexOf 來取得新資料列的索引。 如需詳細資訊,請參閱 DataRowCollectionRows

適用於

另請參閱