问题
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