Copying one DS to another…!


Hi All, This is the code to manually copy one DS to other DS…..
 

Dim objds As New DataSet

Dim dr As DataRow

Dim drTemp As DataRow

Dim datatbl As New DataTable

Dim dc As DataColumn

objds.Tables.Add(datatbl)

Dim newdc As DataColumn

For Each dc In ds.Tables(0).Columns

newdc = New DataColumn(dc.ColumnName.ToString)

objds.Tables(0).Columns.Add(newdc)

Next

Dim I As Integer = 0

For Each dr In ds.Tables(0).Rows

drTemp = datatbl.NewRow()

drTemp.Item(0) = dr.Item(0)

drTemp.Item(1) = dr.Item(1)

drTemp.Item(2) = dr.Item(2)

drTemp.Item(3) = dr.Item(3)

drTemp.Item(4) = dr.Item(4)

objds.Tables(0).Rows.Add(drTemp)

Next

DataGridView2.DataSource = objds.Tables(0).DefaultView

End Sub

Advertisements

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 )

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s

%d bloggers like this: