Vb.net First row as header in datatable

Vb.net First row as header in datatable

I have the datatable

Example:


Solution:

Vb.net Code
'Assign Column Name
For i As Integer = 0 To dtFinalImport.Columns.Count - 1
  If dtFinalImport.Rows.Count > 0 Then
  dtFinalImport.Columns(i).ColumnName = dtFinalImport.Rows(0)(i)
  End If
Next
dtFinalImport.Rows(0).Delete()
dtFinalImport.AcceptChanges()
Result:

Post a Comment

0 Comments