使用Datatable在C#中进行批处理更新 [英] Batch Update in c# using Datatable

查看:1427
本文介绍了使用Datatable在C#中进行批处理更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如何使用数据表在C#中进行批处理更新?

能否请您提供一些演示示例?


在此先感谢您.

Hi,

How to do batch update in c# using data table ?

Can you please provide me some demo example ?


Thanks in Advance.

推荐答案

,您可以构建如下所示的纯文本SQL命令:

you can build a plain-text SQL command like the following:

SqlCommand command = new SqlCommand();
// Set connection, etc.
for(int i=0; i< items.length; i++) {
    command.CommandText += string.Format("update mytable set s_id=@s_id{0} where id = @id{0};", i);
    command.Parameters.Add("@s_id" + i, items[i].SId);
    command.Parameters.Add("@id" + i, items[i].Id);
}
command.ExecuteNonQuery();



您也可以参考以下链接
Perform Bath更新 [批量更新演示 [



And also you can refer the following links
Performing Bath Updates[^].
Batch Update Demo[^].


ZZZ项目批量操作库是您的解决方案.

它使您可以对大量数据执行各种操作,例如:删除,插入,更新和合并.

The ZZZ Projects Bulk Operations Library is the solution for you.

It allows you to effectuate various operations such as: Delete, Insert, Update and Merge on a substantial amount of data.

var operation = new SqlBulkOperation();
 
// ... Custom Settings ....
operation.BulkDelete(dt);
operation.BulkInsert(dt);
operation.BulkUpdate(dt);
operation.BulkMerge(dt);



它还提供了更高级的功能,例如输出值,列公式,审核,拦截,记录等.

http://zzzprojects.com/bulk-operations/上找到有关最先进,最灵活的批量操作库的更多信息.



It also offers more advanced features like output value, column formula, auditing, intercepting, logging and more.

Find out more on http://zzzprojects.com/bulk-operations/ about the most advanced and flexible Bulk Operations library.


这篇关于使用Datatable在C#中进行批处理更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆