SQL Server 2000 - 从数据集/或 C# 集合中批量插入
我知道 SQL Server 2000 有一个批量插入。< /a> 它是否支持从 C# 集合(例如数据集)批量插入?
我需要一次相当规律地插入 30 行。如果不需要的话,我不想为此创建 30 个数据库连接。
I know SQL Server 2000 has a bulk insert. Does it support bulk insert from a C# collection, such as a dataset?
I need to insert 30 rows at a time, fairly regularly. I don't want to create 30 DB connections for this if I don't have to.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看看 SqlBulkCopy (根据论坛 SQL 2000 支持)。它很容易使用。基本上只需为其提供一个数据表(或数据读取器),它就会将行从该源复制到目标表。
Have a look at SqlBulkCopy (has according to forums SQL 2000 support). It's easy to use. Basically just provide it with a data table (or data reader) and it will copy the rows from that source to your destination table.
您可以在 SQL 2000 中使用数据集插入,我从未尝试过,因为我从不使用数据集。
http://www.dotnet247.com/247reference/msgs/3/16570。 aspx 有一篇很好的文章:(
摘自文章)
您考虑过XML吗?
在 SQL 2000 中使用 XML 不如 2008 年那么好,但仍然可行:
http://www.codeproject.com/KB/database/insxmldatasqlsvr.aspx
http://www.codeproject.com/KB/database/generic_OpenXml.aspx
< a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;315968" rel="nofollow noreferrer">http://support.microsoft.com/default.aspx?scid=kb;en-us;315968
您可以考虑的另一个选择是:
You can insert using a DataSet in SQL 2000, I've never tried because I never use DataSets.
http://www.dotnet247.com/247reference/msgs/3/16570.aspx has a good post on it:
(From the article)
Have you considered XML?
Working with XML in SQL 2000 isn't as nice as in 2008, but it is still doable:
http://www.codeproject.com/KB/database/insxmldatasqlsvr.aspx
http://www.codeproject.com/KB/database/generic_OpenXml.aspx
http://support.microsoft.com/default.aspx?scid=kb;en-us;315968
Another option you could look at would be to: