C# 运行语法报错
数据库代码
select top 10 name,(select count(*) from peopleall
where charindex(Area.name,duty)>0
) as strCount from dbo.Area
where 1=1 and layer='4' group by [name] having (selacect count(*) from peopleall where charindex(Area.name,duty)>0)<10
项目方法
protected void chax_Click(object sender, EventArgs e)
{
//获取页面文本框中的数据ac
string distinction = Request.Form["distinction"];
string strlayer = "";
if (distinction == "县级")
{
strlayer = "4";
}
if (distinction == "市级")
{
strlayer = "3";
}
if (distinction == "省级")
{
strlayer = "2";
}
string tiaojian = Request.Form["tiaojian"];
int txtpeople = 0;
if (Request.Form["txtpeople"] != null)
{
txtpeople = Convert.ToInt32(Request.Form["txtpeople"].ToString());
}
wherestr += " and layer='" + strlayer + "'"+" group by [name] having (select count(*) from peopleall where charindex(Area.name,duty)>0)" + tiaojian + txtpeople+"";
//pager.PageSize 默认每页显示20条数据
DataSet ds = SqlHelper.GetPageRecords("GetPageRecordsFidld", "id", 10, pager.CurrentPageIndex, 2, 0, wherestr, tablename, "name,(select count(*) from peopleall where charindex(Area.name,duty)>0) as strCount");
GridView1.DataSource = ds;
this.GridView1.DataBind();
//获取查询的到的条数
CountData(wherestr);
}