首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

关键字 'where' 附近有语法异常

2012-02-07 
关键字 where 附近有语法错误stringsqlstring.Format( Select*from(SELECTdbo.account.id,dbo.account

关键字 'where' 附近有语法错误
string   sql   =   string.Format( "Select   *   from   (   SELECT   dbo.account.id,   dbo.account.name,   dbo.account.description,   dbo.[group].name   AS   GroupName,   dbo.lot_limit.name   AS   LotLimitName, "   +
                        "dbo.money_limit.name   AS   MoneyLimitName   FROM   dbo.account   INNER   JOIN   dbo.[group]   ON   dbo.account.group_id   =   dbo.[group].id   INNER   JOIN   "   +
                        "dbo.lot_limit   ON   dbo.[group].id   =   dbo.lot_limit.group_id   INNER   JOIN   dbo.group_money_limit   ON   dbo.[group].id   =   dbo.group_money_limit.group_id   INNER   JOIN   "   +
                        "dbo.money_limit   ON   dbo.group_money_limit.money_limit_id   =   dbo.money_limit.id   )   where   (dbo.account.name   like   '{0} '   or   dbo.account.description   like   '{1} ')   order   by   dbo.account.id ",
                        this.TextBox1.Text,   this.TextBox1.Text   );

运行出错说是:
关键字   'where '   附近有语法错误。  
Description:   An   unhandled   exception   occurred   during   the   execution   of   the   current   web   request.   Please   review   the   stack   trace   for   more   information   about   the   error   and   where   it   originated   in   the   code.  




[解决办法]
如果你真的喜欢拼字符串的话, 在执行SQL命令时TRY一下,并在CATCH里输出你的SQL命令
[解决办法]
先在查询分析器里执行下
[解决办法]
先把SQL语句输出来看下!

放到查询分析器里面运行下就知道!
[解决办法]
把中間的改為視圖
[解决办法]
直接这样写不行吗?
为什么要加一个子查询
SELECT dbo.account.id, dbo.account.name, dbo.account.description, dbo.[group].name AS GroupName, dbo.lot_limit.name AS LotLimitName,dbo.money_limit.name AS MoneyLimitName FROM dbo.account INNER JOIN dbo.[group] ON dbo.account.group_id = dbo.[group].id INNER JOIN dbo.lot_limit ON dbo.[group].id = dbo.lot_limit.group_id INNER JOIN dbo.group_money_limit ON dbo.[group].id = dbo.group_money_limit.group_id INNER JOIN dbo.money_limit ON dbo.group_money_limit.money_limit_id = dbo.money_limit.id where dbo.account.name like '{0} ' or dbo.account.description like '{1} ') order by dbo.account.id

热点排行