zoukankan      html  css  js  c++  java
  • asp.net 根据dataset获取大字符串(直接转出json)

    方法:

    public static string GetJsonByDataset(DataSet ds)        

    {         

       if (ds == null || ds.Tables.Count <= 0 || ds.Tables[0].Rows.Count <= 0)       

          {              

         return null;          

      }            

      StringBuilder sb = new StringBuilder();          

        foreach (DataTable dt in ds.Tables)            

      {   

                 sb.Append(string.Format("["));             

           foreach (DataRow dr in dt.Rows)             

           {                    

          sb.Append("{");                    

          for (int i = 0; i < dr.Table.Columns.Count; i++)                    

          {                        

            sb.AppendFormat(""{0}":"{1}",", dr.Table.Columns[i].ColumnName, dr[i].ToString());  

                      }                   

            sb.Remove(sb.ToString().LastIndexOf(','), 1);           

                 sb.Append("},");              

           }

                   sb.Remove(sb.ToString().LastIndexOf(','), 1);         

               sb.Append("]");

             }            

       return sb.ToString();      

      }

  • 相关阅读:
    oracle11g 新特性
    RMAN 报:ORA-19504 ORA-27038
    ORACLE-用户常用数据字典的查询使用方法
    oracle
    收缩 表空间
    oracle 配置 oem
    索引大小及占表的空间
    Oracle 11g Windows 迁移至 Linux
    Python:列表生成式
    Python:字符串处理函数
  • 原文地址:https://www.cnblogs.com/jobyym/p/4816978.html
Copyright © 2011-2022 走看看