62,025
社区成员
发帖
与我相关
我的任务
分享
<%@ WebHandler Language="C#" Class="Handler4_GetTypeName" %>
using System;
using System.Web;
using System.Data;
using WindDAL;
using WindModel;
using System.Data.SqlClient;
public class Handler4_GetTypeName : IHttpHandler {
public bool IsReusable
{
get
{
return false;
}
}
HttpContext context;
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
this.context = context;
//context.Response.Write(object);
//context.Response.Write(keywords2);
GetITInfobyKeyword(); //根据关键字查找
}
//根据关键字查找
void GetITInfobyKeyword()
{
IT_CommentDAL dal = new IT_CommentDAL();
string strsql = "select ctypeid,ctypename from CType order by sortid";
DataTable dt = getDatas(strsql);
if (dt.Rows.Count > 0)
{
context.Response.Write(new json().DataTable_Json(dt));
}
}
public DataTable getDatas(string sql)
{
System.Data.DataTable dt = new System.Data.DataTable();
SqlConnection conn = default(SqlConnection);
SqlCommand comm = default(SqlCommand);
string connString = System.Configuration.ConfigurationManager.ConnectionStrings["connString"].ToString();
conn = new SqlConnection(connString);
conn.Open();
comm = new SqlCommand(sql, conn);
comm.CommandTimeout = 0;
SqlDataAdapter da = new SqlDataAdapter(comm);
dt.Clear();
da.Fill(dt);
comm.Dispose();
conn.Close();
conn.Dispose();
return dt;
}
}