Monday, April 16, 2012

Copying Particular Columns from one table to another table without using Loop

Dim columns As String() = {"colA", " colB", "colC", "colD ", "colE"}

Here ds is original dataset
If Not ds Is Nothing Then
  dsDet = ds.Clone

  'Copying only particular columns which is specify in the above string array
  dtDet = ds.Tables(0).DefaultView.ToTable("newTableName", False, columns)
  dsDet.Tables.Add(dtDet)

 'Removing the original table
  dsDet.Tables.RemoveAt(0)
End If

Return dsDetails

No comments:

Post a Comment