.Net - ado.net importing rows vs adding rows?
The DataTable has a method called ImportRow(), There is also 开发者_Go百科a method unders the rows called Add(). So what's the difference between these methods?
dataTable.Rows.Add(newRow);
vs
dataTable.ImportRow(newRow);
- ImportRow preserves any setting of the row: DataRowState,values etc.
- Add calls NewRow that initialize a row using default values.
ImportRow is useful if you're importing a row from another table and you need to preserve all because you're planning to use a DataAdapter
精彩评论