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

      }

  • 相关阅读:
    将VSCode添加至右键菜单(Windows下)
    VSCode 快捷键
    dijkstra 优先队列最短路模板
    运营苹果手机“盗改销”、色情网站的黑产组织追踪
    Wireshark 设置显示端口号
    IDA_API_Help
    IDA配置
    windbg vmware配置
    !heap命令问题 Windbg
    落户
  • 原文地址:https://www.cnblogs.com/jobyym/p/4816978.html
Copyright © 2011-2022 走看看