Tag: DataTable

C# DataTable select method

Author: | Categories: Programming One Comment
DataTable has a Select method. This method receives a string expression that specifies what rows you want to handle. Selection based on a string expression DataRow[] result = table.Select("Size >= 230 AND Sex = 'm'"); Selection based on DateTime DataRow[] result = table.Select("Date > #6/1/2001#"); Number of records for a particular criteria int numberOfRecords = […]

DataTable to HTML Table C# code

Author: | Categories: Database, Programming No Comments
C# DataTable to a HTML Table Below is C# function to generate HTML table string from DataTable with custom options like Custom headers and Selected fields. “Format” in parameters will contain comma separated values like column1=column 1 name, column2=column 2 name and so on. public static string DataTableToHtmlTable(DataTable TableData, string Format) { try { Dictionary<string, […]

Datatable to CSV file

Author: | Categories: Database, Programming No Comments
C# DataTable to a CSV file C# DataTable to a CSV file with default options i.e. all columns with default column names public static string DataTableToCsvFile(DataTable TableData, string FileName) { try { // change this with any delimiter you want string Delimiter = ","; int i = 0; StreamWriter sw = null; sw = new […]