将大量记录插入数据库访问的最佳方法 [英] Best Way to insert large amount of records to database access

查看:83
本文介绍了将大量记录插入数据库访问的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我有一个包含电子邮件的csv文件



i想要读取这些值一个通过一个并验证他们将它们插入到访问数据库,但是上传大量的记录需要时间



有没有办法快速插入大数字



注意:我从csv文件中读取记录并将它们插入数据表中,然后逐行检查它们以验证并插入它们



谢谢,

Hey

I have a csv file that contain Emails

i want to read these values one by one and validate them them insert them to a access database but on uploading a large amount of records it take time

is there a way to insert large number quickly

Note: i read the records from the csv file and insert them in a datatable then check them row by row to validate and insert them

thank,

推荐答案

Access数据库不支持批量插入等任何内容。您必须像现在一样逐个插入记录。但是,通过创建参数化INSERT查询命令对象,为其设置OleDbParameter对象,然后在命令对象上调用Prepare,可以获得性能提升。在解析和验证CSV文件中的记录后,仍然必须设置参数的值。但是,执行insert命令将不会花费很长时间,如果它已准备好。
Access databases do not support anything like a Bulk Insert. You have to insert the records one-by-one, like you are now. But, you can get a bit of a performance improvement by creating your parameterized INSERT query command object, setting up your OleDbParameter objects for it, then calling Prepare on the command object. You still have to set the values of the parameters after you parse and validate a record from your CSV file. But, executing the insert command won't take as long if it's Prepared.


这篇关于将大量记录插入数据库访问的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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