如何在C#中逐步发送批量记录 [英] How to send bulk record step by step in C#

查看:73
本文介绍了如何在C#中逐步发送批量记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在列表中有5000条记录,所以我必须先发送1000条记录然后在下一次迭代中接下来的1000条记录,即1001到2000这样我必须逐步发送所有记录



我尝试了什么:



i有循环的treid,但它对我不起作用

I have 5000 records in list so i have to send first 1000 record then in next iteration next 1000 record ie 1001 to 2000 in this way i have to send all the record step by step

What I have tried:

i have treid for loop but its not working for me

推荐答案

假设这是一个数据库...

有很多方法可以做到这一点,但最简单的可能就是创建一个DataTable,加载它有1000行,并使用 SqlBulkCopy类( System.Data.SqlClient) [ ^ ]将其加载到数据库。

这里有一个使用SqlBulkCopy的例子:多个SQL使用单个命令INSERT操作 [ ^ ]可能会有所帮助。
Assuming this is to a database...
There are a load of ways to do this, but the simplest is probably to create a DataTable, load it with 1000 rows, and use the SqlBulkCopy Class (System.Data.SqlClient)[^] to load it to the DB.
There is an example of using SqlBulkCopy here: Multiple SQL INSERT Operations with a Single Command[^] which may be of help.


这篇关于如何在C#中逐步发送批量记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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