C# 运行语法报错

heyansong221 2011-11-12 01:39:33
数据库代码
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);
}
...全文
107 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
勿勿 2011-11-14
  • 打赏
  • 举报
回复
正解
[Quote=引用 1 楼 roy_88 的回复:]
SQL code
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 (select count(*) from peo……
[/Quote]
heyansong221 2011-11-14
  • 打赏
  • 举报
回复
那为什么在数据库能执行,在项目里面报group 语法错误
你说的哪个select country(*)错误 那里还真没错。或许是你看错了
--小F-- 2011-11-12
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 roy_88 的回复:]
SQL code
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 (select count(*) from peo……
[/Quote]
眼力真好。
中国风 2011-11-12
  • 打赏
  • 举报
回复
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 (select count(*) from peopleall where charindex(Area.name,duty)>0)<10



(selacect count(*)--这里不正确

27,579

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 应用实例
社区管理员
  • 应用实例社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧