DataTable.ImportRow(DataRow) 方法
定义
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)
参数
注解
调用 NewRow 使用现有的表架构将行添加到表中,但对于行使用默认值,并将设置 DataRowState 为 Detached
。Calling NewRow adds a row to the table using the existing table schema, but with default values for the row, and sets the DataRowState to Detached
. 调用 ImportRow 将保留现有的 DataRowState 和行中的其他值。Calling ImportRow preserves the existing DataRowState along with other values in the row. 如果 DataRow
作为参数传递的处于已分离状态,则将其忽略,并且不会引发异常。If the DataRow
that is passed as a parameter is in a detached state, it is ignored, and no exception is thrown.
新行将添加到数据表的末尾。The new row will be added to the end of the data table.
如果新行违反约束,则不会将其添加到数据表。If the new row violates a Constraint it won't be added to the data table.
可以获取新行的索引,其形式为 DataTable. IndexOf 和 DataTable。You can get the index of the new row with as DataTable.Rows.Find and DataTable.Rows.IndexOf. 有关更多信息,请参见DataRowCollection和Rows。See DataRowCollection and Rows for more information.