1
我有這個VB腳本正在第三方應用程序中運行,並且正在拋出「期望的語句結束」錯誤,下面是有問題的代碼:SELECT語句在SQL服務器管理器中正常工作工作室。聲明錯誤的預期結束
感謝。
Dim SecurityDB
Set SecurityDB = CreateObject("ADODB.Connection")
Conn = "DRIVER={SQL Server};SERVER=ustcca015s6\Continuum;DATABASE=continuumdb;UID=Andy8796;PWD=xxxx1234;"
SecurityDB.Open Conn
Set EmployeeRS = SecurityDB.Execute "Select count(*) from dbo.personnel where state=1 and lastname not like 'lapt%' and lastname is not NULL and valuelo in (Select ObjectIdLo from area where uiname like 'usmm%' and uiname not like '%gate%') and valuelo <> 1111497912;"
Result = EmployeeRS.GetRows
EmployeeRS.Close
SecurityDB.Close
執行後不需要括號嗎? 'Set EmployeeRS = SecurityDB.Execute(「Select count(*)from dbo.personnel where state = 1 and lastname not like'lapt%'and lastname is not NULL and valuelo in(從使用uiname的地方選擇ObjectIdLo'usmm%'和uiname不喜歡'%gate%')和valuelo <> 1111497912;「)' – RichardTheKiwi
@RichardTheKiwi的評論是正確的:只有一個'sub'(不返回返回值的例程)可以在沒有括號的情況下被調用。如果你正在調用'function',那麼括號是強制性的。查看'MsgBox「進程終止,」vbOKOnly「和'answer = MsgBox(」你想終止進程嗎?「,vbYesNo)之間的區別' – AutomatedChaos
@RichardTheKiwi:爲什麼不作爲回答發佈? – Helen