Handling a large ADODB record set in data table?

隐身守侯 提交于 2020-01-17 13:42:37

问题


I am loading a large result set of about 3 million rows (ADODB record set) into a data table. Its taking too long to even load the result set into a data table. I want to find out a way of extracting only part of a result set and then loading it into a DataTable. Alternatively, is there a way to directly read the recordset directly instead of loading it into a data table and then reading it ?

This is the code I use to fill my DataTable -

OleDbDataAdapter oleDA = new OleDbDataAdapter();
DataTable dt = new DataTable();
oleDA.Fill(dt, myADODBRecordset);

回答1:


Here are some options to consider:

  1. Get only the rows and columns you really need to work with.

  2. Get some data and let the user ask for the next set of rows when they want to.

  3. Write optimized SQL queries

  4. Don't use a DataTable unless you have to because it contains more metadata information that other list-type objects.

  5. Consider using a managed .NET provider.




回答2:


Why load so large data into memory? A large data transaction must comsume large resource, so optimize your code, or use EF.



来源:https://stackoverflow.com/questions/19918848/handling-a-large-adodb-record-set-in-data-table

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!