Posted By

keidash on 03/29/10


Tagged

edit make datatable


Versions (?)

Make and edit DataTable in code


 / Published in: VB.NET
 

Como crear un DataTable a mano y editar sus columnas y filas bajo código.

  1. Private Sub InitDataset()
  2. Dim lDataTable As New DataTable
  3. Dim lDataColum As DataColumn
  4. Dim lDataRow As DataRow
  5.  
  6. lDataColum = New DataColumn
  7. lDataColum.DataType = System.Type.GetType("System.String")
  8. lDataColum.ColumnName = "FileName"
  9. lDataTable.Columns.Add(lDataColum)
  10.  
  11. lDataColum = New DataColumn
  12. lDataColum.DataType = System.Type.GetType("System.String")
  13. lDataColum.ColumnName = "Extension"
  14. lDataTable.Columns.Add(lDataColum)
  15.  
  16. lDataColum = New DataColumn
  17. lDataColum.DataType = System.Type.GetType("System.String")
  18. lDataColum.ColumnName = "Lenght"
  19. lDataTable.Columns.Add(lDataColum)
  20.  
  21. lDataColum = New DataColumn
  22. lDataColum.DataType = System.Type.GetType("System.Date")
  23. lDataColum.ColumnName = "Date"
  24. lDataTable.Columns.Add(lDataColum)
  25.  
  26. mDts = New DataSet
  27. mDts.Tables.Add(lDataTable)
  28. End Sub

Report this snippet  

You need to login to post a comment.