Return to Snippet

Revision: 28731
at August 7, 2010 07:50 by derebus


Updated Code
'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

Revision: 28730
at July 14, 2010 00:13 by derebus


Updated Code
'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
    IdNivel = dtAntiguo.Rows(i)("idEmployee")
    nombreNivel = dtAntiguo.Rows(i)("nombreEmployee")
    dtNuevo.Rows.Add(j)("idEmployee") = IdEmployee
    dtNuevo.Rows(j)("nombreEmployee") = nombreEmployee
Next

Revision: 28729
at July 13, 2010 09:04 by derebus


Initial Code
'Primero le copiamos la estructura del datatable 
dtNuevo.Columns.Add(dtAntiguo.Columns(0).ColumnName) 'columna 0
dtNuevo.Columns.Add(dtAntiguo.Columns(1).ColumnName) '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
    IdNivel = dtAntiguo.Rows(i)("idEmployee")
    nombreNivel = dtAntiguo.Rows(i)("nombreEmployee")
    dtNuevo.Rows.Add(j)("idEmployee") = IdEmployee
    dtNuevo.Rows(j)("nombreEmployee") = nombreEmployee
Next

Initial URL


Initial Description
Copiando las columnas y la data que deseamos de un datatable a otro

Initial Title
Copia columnas de un datatable a otro (específicas)

Initial Tags


Initial Language
Visual Basic