/ Published in: VB.NET
Howto create a new datatable manually
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
Public Function CreateDatatable() as DataTable ' Create new datatable Dim mydatatable As New DataTable ' Create columns mydatatable.Columns.Add("field_a", Type.GetType("System.String")) mydatatable.Columns.Add("field_b", Type.GetType("System.String")) ' Declare row Dim myrow As DataRow ' create new row myrow = mydatatable.NewRow myrow("field_a") = "filed a row 1" myrow("field_b") = "filed b row 1" mydatatable.Rows.Add(myrow) ' create another row myrow = mydatatable.NewRow myrow("field_a") = "filed a row 2" myrow("field_b") = "filed b row 3" mydatatable.Rows.Add(myrow) ' return the datatable filled with 2 columns and rows return mydatatable End Sub