gpt4 book ai didi

vb.net - rows.add 和 importRow 之间的区别

转载 作者:行者123 更新时间:2023-12-03 05:19:59 26 4
gpt4 key购买 nike

在vb.net中向数据表添加行时,rows.add和importRow有什么区别?

Dim dt As DataTable
Dim dr As DataRow

'Add row this way...
dt.rows.add(dr)

'or this way.
dt.importRow(dr)

最佳答案

两者都执行相同的功能,将行添加到数据表,但主要区别是

    DataTable dt1=new DataTable();
DataRow dr1=dt1.NewRow();
DataTable dt2=new DataTable();
dt2.Rows.Add(dr1); // will give you error already dr1 belongs to another datatable in that //case you can do like this
dt2.ImportRow(dr1); // safe
dt1.Rows.Add(dr1); // safe as dr1 Row belongs to DataTable1 so no exception raise

希望能给你一个想法..

关于vb.net - rows.add 和 importRow 之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5140158/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com