Working with DataTables

  • myString = myDatatable.Rows(1)(3).ToString() [retrieves the item from the second row and fourth column of the datatable]
  • Columns.RemoveAt(2) [deletes the third column of the datatable]*
  • doesContain = myDatatable.Columns.Contains("Total") [checks if datatable has a column named "Total" and returns true/false]
  • myIndex = myDatatable.Columns.IndexOf("Total") [returns the index of the column named "Total"]
  • drSelection = dt.Select("Lastname = 'Mayer'") [returns array of DataRows with all rows where the value of column "Lastname" is equal to "Mayer"]
  • drOrderedSelection = dt.Select("Lastname = 'Mayer'", "Age ASC") [returns an on column age ascendingly ordered array of DataRows with all rows where the value of column "Lastname" is equal to "Mayer"]
  • myRowString = String.Join(" | ", row.ItemArray.Select(Function(p) p.ToString())) [combines all values of a given DataRow to a string, values are seperated by " | "]
Was this article helpful?
0 out of 0 found this helpful