2017-08-21 119 views
0
Dim sql As String = "SELECT DISTINCT LED.IDX As IDX, CORPCODE, UNITTYPECODE, UPPERFORMATIONCODE, FORMATIONCODE, LED.UNITCODE As UNITCODE,LED.STORECODE As STORECODE, LED.SECTIONNO As SECTIONNO, LED.PARTNO As PARTNO, " 
      sql &= " LED.BATCHNO As BATCHNO, UNITITEMCATEGORYCODE, LEDGERDATE, ENTITLEMENT, HOLDING, SURPLUS, SHORTAGE, COSTHOLDING, COSTENTITLEMENT, INITIALSTOCK, EMPLOYQTY, FIGHTQTY, ITEMAGE1, ITEMAGE2, ITEMAGE3," 
      sql &= " ITEMAGE4, LED.BAH_BEREK, LED.JENIS_BEREK, JPTD_NO, LASTUPDATE, LED.ITEMTYPECODE As ITEMTYPECODE, LED.TOOLTYPECODE As TOOLTYPECODE, LED.PAKAIBHGCODE, LED.PAKAICODE, ITEMNIDX, LED.CREATEID As CREATEID, " 
      sql &= " LED.UPDATEID As UPDATEID, LED.CREATEDATE As CREATEDATE, LED.UPDATEDATE As UPDATEDATE, " 
      sql &= " USERID, RANKCODE, SERVICENO, USERNAME, DESIGNATIONCODE, PASSWORD, " 
      sql &= " 'OPER' AS GROUPCODE,5 AS ACESSID, 0 AS STATUS " 
      sql &= " FROM (LEDGER AS LED) " 
      sql &= " LEFT JOIN NUSER On NUSER.USERID = LED.UPDATEID WHERE (1=1) " 
      If condation <> "" Then 
       sql += condation 
      End If 
      sql &= " UNION SELECT DISTINCT LED.IDX As IDX, CORPCODE, UNITTYPECODE, UPPERFORMATIONCODE, FORMATIONCODE, LED.UNITCODE As UNITCODE, LED.STORECODE As STORECODE, LED.SECTIONNO As SECTIONNO, LED.PARTNO As PARTNO, " 
      sql &= " LED.BATCHNO As BATCHNO, UNITITEMCATEGORYCODE, LEDGERDATE, ENTITLEMENT, HOLDING, SURPLUS, SHORTAGE, COSTHOLDING, COSTENTITLEMENT, INITIALSTOCK, EMPLOYQTY, FIGHTQTY, ITEMAGE1, ITEMAGE2, ITEMAGE3," 
      sql &= " ITEMAGE4, LED.BAH_BEREK, LED.JENIS_BEREK, JPTD_NO, LASTUPDATE, LED.ITEMTYPECODE As ITEMTYPECODE, LED.TOOLTYPECODE As TOOLTYPECODE, LED.PAKAIBHGCODE, LED.PAKAICODE, ITEMNIDX, LED.CREATEID As CREATEID, " 
      sql &= " LED.UPDATEID As UPDATEID, LED.CREATEDATE As CREATEDATE, LED.UPDATEDATE As UPDATEDATE," 
      sql &= " ('' AS USERID), ('' AS RANKCODE),('' AS SERVICENO),('' AS USERNAME),('' AS DESIGNATIONCODE), ('' AS PASSWORD), 'OPER',5 , STATUS " 
      sql &= " FROM LEDGER_HISTORY LED WHERE (1=1) " 

錯誤是查詢表達式'(''USER USERID)'中的語法錯誤(缺少運算符)。 任何人都可以幫我解決這個問題查詢表達式中的語法錯誤(缺少運算符)

回答

1

錯誤是正確的。問題是括號。

這個語法是不恰當的SQL:

SELECT ('' AS USERID) 

然而,這就是:

SELECT ('') AS USERID 

或者只是:

SELECT '' AS USERID 

您與FROM (LEDGER AS LED)有同樣的問題。

+0

非常感謝你..但它仍然無法正常工作..一旦我做了,這個錯誤出來了:SELECT語句包括一個保留字或參數名拼寫錯誤或缺少,或標點符號不正確。 –

相關問題