//多表多行多列的情況 foreach (DataTable dt in YourDataset.Tables) //遍歷所有的datatable { foreach (DataRow dr in dt.Rows) ///遍歷所有的行 foreach (DataColumn dc in dt.Col
//多表多行多列的情況
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());
}