关于我们

质量为本、客户为根、勇于拼搏、务实创新

< 返回新闻公共列表

数据库查询结果输出json

发布时间:2019-11-19 16:59:38
  1. <%@ WebHandler Language="C#" Class="DTcms.Web.dev.thd" %>
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Web;
  5. using System.Web.SessionState;
  6. using System.IO;
  7. using System.Text;
  8. using System.Data;
  9. using System.Data.Sql;
  10. using System.Data.SqlClient;
  11. using DTcms.Common;
  12. using DTcms.DBUtility;
  13. using NetWing.Common.Data.SQLServer;
  14. using NetWing.Common.Request;
  15. namespace DTcms.Web.dev
  16. {
  17.    /// <summary>
  18.    /// 通用-城市 的摘要说明
  19.    /// </summary>
  20.    public class thd : IHttpHandler, IRequiresSessionState
  21.    {
  22.        public void ProcessRequest(HttpContext context)
  23.        {
  24.            context.Response.ContentType = "text / plain";
  25.            //获取参数开始
  26.            string type = context.Request["type"];
  27.            switch (type)
  28.            {
  29.                case "area"://地名
  30.                    DataTable dt = SqlEasy.ExecuteDataTable("select  * from nw_customform_user_area where region_name like '%" + context.Request["area"] + "%'");
  31.                    string json = JsonHelper.DataTableToJSON(dt);
  32.                    context.Response.Write(json);
  33.                    break;
  34.                case "id"://提货点id
  35.                    DataTable dtid = SqlEasy.ExecuteDataTable("select  * from nw_customform_user_area where id="+context.Request["id"]+"");
  36.                    string jsonid = JsonHelper.DataTableToJSON(dtid);
  37.                    context.Response.Write(jsonid);
  38.                    break;
  39.                default:
  40.                    break;
  41.            }
  42.  
  43.  
  44.        }
  45.  
  46.        public bool IsReusable
  47.        {
  48.            get
  49.            {
  50.                return false;
  51.            }
  52.        }
  53.    }
  54. }



/template/Home/Zkeys/PC/Static