/ Published in: Visual Basic

Copiando las columnas y la data que deseamos de un datatable a otro
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
'Primero le copiamos la estructura del datatable dtNuevo.Columns.Add(dtAntiguo.Columns(0).ColumnName) 'copia columna 0 dtNuevo.Columns.Add(dtAntiguo.Columns(1).ColumnName) 'copia columna 1 'Ahora copiamos la data del datatable a nuestras nuevas columnas Dim IdEmployee As String Dim nombreEmployee As String For i As Integer = 0 To dtAntiguo.Rows.Count - 1 Dim j As Integer = dtNuevo.Rows.Count IdEmployee= dtAntiguo.Rows(i)("idEmployee") nombreEmployee= dtAntiguo.Rows(i)("nombreEmployee") dtNuevo.Rows.Add(j)("idEmployee") = IdEmployee dtNuevo.Rows(j)("nombreEmployee") = nombreEmployee Next
Comments
