//多表多行多列的情况
foreach (DataTable dt in YourDataset.Tables) //遍历所有的datatable
{
foreach (DataRow dr in dt.Rows) ///遍历所有的行
foreach (DataColumn dc in dt.Columns) //遍历所有的列
Console.WriteLine(“{0}, {1}, {2}”, dt.TableName,
dc.ColumnName, dr[dc]); //表名,列名,单元格数据
}
//遍历一个表多行多列
foreach(DataRow mDr in dataSet.Tables[0].Rows )
{
foreach(DataColumn mDc in dataSet.Tables[0].Columns)
{
Console.WriteLine(mDr[mDc].ToString());
}
}
//遍历一个表多行一列
foreach(DataRow row in DataSet1.Tables[0].Rows)
{
Console.WriteLine(row[0].ToString());
}