//多表多行多列的狀況
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){
//多表多行多列的狀況
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, it
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());
}table
//一行一列
ds.Tables[0].Rows[0]["字段"]class