There are several ways to print or display the contents of a DataTable:
foreach (DataRow row in dataTable.Rows)
{
foreach (DataColumn col in dataTable.Columns)
{
Console.Write(row[col] + "\t");
}
Console.WriteLine();
}
WriteXml
method to write the contents to an XML file:dataTable.WriteXml("data.xml");
dataGridView.DataSource = dataTable;
var results = from DataRow row in dataTable.Rows
select row["ColumnName"];
foreach (var row in results)
{
Console.WriteLine(row);
}
Asked: 2023-04-30 00:04:55 +0000
Seen: 10 times
Last updated: Apr 30 '23