关键字附近的语法不正确

时间:2012-12-26 08:36:25

标签: sql-server vb.net

我有一个sql语句在sql server上成功运行但在vb.net上粘贴时语法问题不正确。关键字'.''endfrom''group'附近的语法不正确。

sql = "select distinct y.supplierID, y.Name," & _
             "StatusDesc=CASE when  y.status='N' then 'NEW' " & _
             "when y.status='B' then 'BLACKLISTED'" & _
             "when y.status='Q' then 'QUALIFIED'" & _
             "when y.status='R' then 'REJECTED' end , " & _
             "FlowStatusDesc = CASE when y.flowstatus='RC' then 'UNDER REVIEW'" & _
             "when y.flowstatus='PE' then 'POTENTIAL EXCLUSIVE'" & _
             "when y.flowstatus='PO' then 'POTENTIAL ORDINARY' ELSE '' end," & _
             "orderno=case when y.status='N' and y.flowstatus='' then '1'" & _
             "when y.status='N' and y.flowstatus<>'' then '2'   " & _
             "when y.status='R' and y.flowstatus='' then '3'" & _
             "when y.status='R' and y.flowstatus<>'' then '4'" & _
             "when y.status='Q' and y.flowstatus='' then '5'" & _
             "when y.status='Q' and y.flowstatus<>'' then '6'" & _
             "when y.status='B' and y.flowstatus=''  then '7' " & _
             "when y.status='B' and y.flowstatus<>'' then '8' else '9' end " & _
             "from (select x.supplierID, x.Name,x.Status,x.FlowStatus,x.AddWho" & _
             "from dbo.AP_Supplier x where x.AddWho IN (Select  distinct b.UserID from dbo.SC_UserRole a left join dbo.SC_UserRole b ON a.RoleID=b.RoleID where a.UserID=@User)" & _
             "group by x.supplierID,x.Name,x.Status,x.FlowStatus,x.AddWho)y " & _
             "group by y.supplierID,y.name,y.status, y.flowstatus" & _
             "order by orderno"

1 个答案:

答案 0 :(得分:2)

在所有行的末尾插入空格。 E.g。

"group by y.supplierID,y.name,y.status, y.flowstatus" & _
"order by orderno"

产生字符串

group by y.supplierID,y.name,y.status, y.flowstatusorder by orderno

这是语法错误。