Script(s)

what I learn is what u c

Recordset to Datatable (Asp.Net)

leave a comment »

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)

Advertisements

Written by gchandra

January 19, 2007 at 1:17 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: