zoukankan      html  css  js  c++  java
  • C#遍历DataSet中数据的几种方法总结

    //多表多行多列的情况

    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());

         }

  • 相关阅读:
    python logging模块
    python re模块
    python xml模块
    python json,pickle,shelve模块
    python os,sys模块
    python 临时添加环境变量
    python random模块
    python time模块
    python 装饰器的简单使用
    python学习之路(二)
  • 原文地址:https://www.cnblogs.com/nxxshxf/p/5227739.html
Copyright © 2011-2022 走看看