你好:)
楼上的代码是可以的。因为DataTable无论你做增删改查,都是在内存中进行的。和数据库毫无关系。
同时,每次做了操作之后,DataTable中的某个行(DataRow)会自动维护状态(比如添加到DataTable中的状态是Added,删除的是Deleted等)。然后你Update,该方法内部使用类似foreach的循环遍历整个DataRow,获取状态,动态根据状态判断调用Insert,Delete还是Update语句。
如果你有其它意见或私下交流,请直接发送maledong_work@foxmail.com;或者
If you do not have QQ, please
open the page and download it
and click the image to talk or leave message for me.
下载MSDN桌面工具(Vista,Win7)
下载Technet桌面小工具(Vista,Win7)
慈善点击,点击此处