Working with ADODB recordset

随声附和 提交于 2021-01-28 11:51:07

问题


I am using VS 2010. The requirement to pull the ADODB recordset and convert them into DataTable. Is there any extension method or library available in ASP.NET to convert ADODB recordset to Datatable.

I can understand using OleDataAdapter we can achieve it. But I am curious to know is there any utility available in ASP.net so that I can make use of it.


回答1:


This is one of the simple approaches which helps you to convert ADODB Recordset to DataTable.

 public static DataTable ADODBRSetToDataTable(this ADODB.Recordset adodbRecordSet)
  {
                OleDbDataAdapter dataAdapter = new OleDbDataAdapter();
                DataTable dt = new DataTable();
                dataAdapter.Fill(dt,adodbRecordSet);
                return dt;
  }

Ensure you have made a reference to Microsoft ActiveX Data Objects 2.0 library or >

Note : I haven't tested the code.



来源:https://stackoverflow.com/questions/17387930/working-with-adodb-recordset

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