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. 

解决方案 »

  1.   

    如果你真的喜欢拼字符串的话, 在执行SQL命令时TRY一下,并在CATCH里输出你的SQL命令
      

  2.   

    先把SQL语句输出来看下!放到查询分析器里面运行下就知道!
      

  3.   

    直接这样写不行吗?
    为什么要加一个子查询
    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
      

  4.   

    呵呵,kellynt() 的答案非常不错,我晕了头了,谢谢了,^_^
      

  5.   

    已经搞掂了,多谢各位热情洋溢的回复。
    呵呵,^_^
    TKS a lot!!!~~~~~~~~~~~~~~