本文介绍了使用SqlBulkCopy的插入/更新数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我与records.I'm插入记录使用SqlBulkCopy.It SQL表的DataTable工作fine.Next时候用得到相同的记录DataTable中很少改变的值是SqlBulkCopy的插入另一组的记录,但不更新previous details.How可以使用使用SqlBulkCopy我更新SQL表?请帮助。

I have a datatable with the records.I'm inserting records into Sql table using SqlBulkCopy.It works fine.Next time when get the datatable with same records with few changed values SqlBulkCopy is inserting another set of records without updating the previous details.How can I update the Sql table using SqlBulkCopy ?? Please help.

谢谢,
Vix指数

Thanks,Vix

推荐答案

SqlBulkCopy的仅用于插入记录,不更新他们作为解释的。你需要使用不同的技术做批量更新。

SqlBulkCopy is only used for inserting records, not updating them as explained here. You'd need to use a different technique to do bulk updates.

例如。你可以使用SqlBulkCopy到一个临时表中,然后运行一些SQL从那里来更新到主表。

e.g. you could SqlBulkCopy into a staging table, then run some SQL to update from there to the main table.

这篇关于使用SqlBulkCopy的插入/更新数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 16:47