Recordset to Datatable (Asp.Net)
If you are migrating your application from Asp to Asp.Net, Recordsets to Datatable will be key issue.
If you want to utilize the power of Datagrid or any Asp.net controls then DataTable and DataSets is the way to go.
Fortunately converting Recordset to DataTable or DataSet is very easy.
Steps
1 . Create an OleDb DataAdapter
2. Create a DataTable Object
3. Fill the Adapter with Recordset values.
4. Add DataTable to DataSet (if needed)
Now the coding part
Dim MyAdapter As OleDbDataAdapter = New OleDbDataAdapter() Dim <strong>dtRSTable</strong> As System.Data.DataTable = New DataTable() MyAdapter.Fill(<strong>dtRSTable</strong>, Rs) Now <strong>dtRSTable</strong> is ready. This dtRSTable can be directly referenced in a datagrid or added to DataSet dgSampleGrid.datasource = dtRSTable.Defaultview dgSampleGrid.databind 'or 'Adding DataTable to DataSet dim dsTable as New DataSet dsTable.Tables.Add(dtRSTable)
Leave a Reply