开发者

.Net - ado.net importing rows vs adding rows?

开发者 https://www.devze.com 2023-04-07 13:40 出处:网络
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?

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

0

精彩评论

暂无评论...
验证码 换一张
取 消