各位大侠,本人.net菜鸟,想请教一个问题:我想遍历dataset中某个表的某个字段的所有记录,请问怎么实现??在线等,谢谢了!!

解决方案 »

  1.   

            DataSet dataSet = new DataSet();
            foreach (DataRow dataRow in dataSet.Tables[0].Rows)
            {
                string a = dataRow["xx"] as string;
            }
    遍历第一个表的xx字段。
      

  2.   

    for (int i = 0; i < ds.Tables["tb_name"].Rows.Count; i++)
                {
       MessageBox.Show(ds.Tables["tb_name"].Rows[i]["字段名"].ToString(), "提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
                }
      

  3.   


    for(int k=0;k<dataSet1.Table[0].Rows.Count;k++)//总共有多少行 

    for(int p=1;p<dataSet1.Table[0].Columns.Count;p++)//每行有多少列 

     //dataSet1.Table[0].Rows[k].ItemArray.GetValue(p).ToString() ;行列对应的数据 


      

  4.   

    dataSet1.Table[0].Rows[k].ItemArray.GetValue(p).ToString() 
    ItemArray.GetValue(p)这是什么意思??
      

  5.   

    ds.Tables["tb_name"].Rows[i]["字段名"].ToString(), 
    就这个意思 、哈哈
    你按照这个写吧