我打算從EXCEL撈SQL的資料
但每次都會出現如題的訊息
是否能夠幫我看看到底哪裡的問題,
或者是否有驗證錯誤的方法@@
Sub logsheet()
Dim ad, start_time, End_Time, eq_period, critera1, critera2 As String
Application.ScreenUpdating = False
ad = InputBox("請輸入lotid")
ad = ucase(ad)
start_time = InputBox("請輸入start_time,例如:yyyy/mm/dd", , Date - 3)
end_time = InputBox("請輸入end_time,例如:yyyy/mm/dd", , Date + 1)
start_time = Format(start_time, "yyyy-mm-dd hh:mm:ss")
end_time = Format(end_time, "yyyy-mm-dd hh:mm:ss")
c1 = " WHERE AA1='" + ad + "' AND AA2='GG' AND AA4='W' AND AA3='T' AND
TIME >{ts '" + start_time + "'} AND TIME < {ts '" + end_time + "'}"
With Sheets("logsheet").Range("B1").QueryTable
.connection = "ODBC;DSN=****;UID=****;PWD=****;SERVER=****;"
.CommandText = "SELECT s.ad,s.st FROM AB1 " + c1
.Refresh BackgroundQuery:=False
End With
End Sub