0
Digg me

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

[sourcecode language='vb']
Dim MyAdapter As OleDbDataAdapter = New OleDbDataAdapter()

Dim dtRSTable As System.Data.DataTable = New DataTable()

MyAdapter.Fill(dtRSTable, Rs)

Now dtRSTable 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)

[/sourcecode]