< 返回新闻公共列表
数据库查询结果输出json
发布时间:2019-11-19 16:59:38
- <%@ WebHandler Language="C#" Class="DTcms.Web.dev.thd" %>
- using System;
- using System.Collections.Generic;
- using System.Web;
- using System.Web.SessionState;
- using System.IO;
- using System.Text;
- using System.Data;
- using System.Data.Sql;
- using System.Data.SqlClient;
- using DTcms.Common;
- using DTcms.DBUtility;
- using NetWing.Common.Data.SQLServer;
- using NetWing.Common.Request;
- namespace DTcms.Web.dev
- {
- /// <summary>
- /// 通用-城市 的摘要说明
- /// </summary>
- public class thd : IHttpHandler, IRequiresSessionState
- {
- public void ProcessRequest(HttpContext context)
- {
- context.Response.ContentType = "text / plain";
- //获取参数开始
- string type = context.Request["type"];
- switch (type)
- {
- case "area"://地名
- DataTable dt = SqlEasy.ExecuteDataTable("select * from nw_customform_user_area where region_name like '%" + context.Request["area"] + "%'");
- string json = JsonHelper.DataTableToJSON(dt);
- context.Response.Write(json);
- break;
- case "id"://提货点id
- DataTable dtid = SqlEasy.ExecuteDataTable("select * from nw_customform_user_area where id="+context.Request["id"]+"");
- string jsonid = JsonHelper.DataTableToJSON(dtid);
- context.Response.Write(jsonid);
- break;
- default:
- break;
- }
-
-
- }
-
- public bool IsReusable
- {
- get
- {
- return false;
- }
- }
- }
- }