if (cznr.Text.Trim() != "")
{
cznrsql += " and (isnull(a.usr,'') like '%" + cznr.Text.Trim() + "%') ";
}
if (rbv != "2")
{
cznrsql += " and (c.gs = " + rbv + " ) ";
}
string sql = "SELECT count(*) as rcount FROM smsusr a left join smsusr_group c on a.groupid = c.id" + cznrsql;
System.Data.SqlClient.SqlException: 第 1 行: '=' 附近有语法错误。
{
cznrsql += " and (isnull(a.usr,'') like '%" + cznr.Text.Trim() + "%') ";
}
if (rbv != "2")
{
cznrsql += " and (c.gs = " + rbv + " ) ";
}
string sql = "SELECT count(*) as rcount FROM smsusr a left join smsusr_group c on a.groupid = c.id" + cznrsql;
System.Data.SqlClient.SqlException: 第 1 行: '=' 附近有语法错误。
string cznrsql = "where ( 1=1 ) ";
if (cznr.Text.Trim() != "")
{
cznrsql += " and (isnull(a.usr,'') like '%" + cznr.Text.Trim() + "%') ";
}
if (rbv != "2")
{
cznrsql += " and (c.gs = " + rbv + " ) ";
}
string sql = "SELECT count(*) as rcount FROM smsusr a left join smsusr_group c on a.groupid = c.id" + cznrsql;
string sql = "SELECT count(*) as rcount FROM smsusr a left join smsusr_group c on a.groupid = c.id" + cznrsql;
在局部变量窗口看看 sql 的值是什么。copy出来到查询分析器去执行一下。看看对不对还有
if (rbv != "2")
可能是null
改为 if (rbv != "2" && rbv!=null)
我今天就遇到了后面这个错误.
c.idwhere...
你看看rbv是否为空
cznrsql += " and (c.gs = " + rbv + " ) ";
改为:cznrsql += " and (c.gs = '" + rbv + "' ) ";