Sub Run()
Call ConnectDB
Dim Cmd As ADODB.Command
Dim rcs As ADODB.Recordset
Dim SQL As String
Dim res() As String
Set Cmd = New ADODB.Command
Set Cmd.ActiveConnection = con
SQL = "select tl.id, al.price_crossing, al.price_exchange_fees, tl.charges_execution, tl.charges_mariana, tl.charges_exchange, tl.trade_date, un.value, tl.nb_crossing from mfb.trade_leg tl" & _
"inner join mfb.trade t on t.id = tl.id_trade" & _
"inner join mfb.instrument i on t.id_instrument = i.id" & _
"inner join mfb.instrument_type it on it.id = i.id_instrument_type" & _
"inner join mfb.options o on o.id_instrument = i.id" & _
"inner join mfbref.mfb.underlying un on un.id = o.id_underlying" & _
"inner join mfb.allocation_leg al on al.id_trade_leg = tl.id" & _
"where tl.trade_date > '20160101' and t.state = 3"
Cmd.CommandText = SQL
Set rcs = Cmd.Execute()
每當我執行此代碼時,出現調試錯誤,提示'tl'附近的語法不正確。我嘗試以不同的方式執行SQL,但錯誤不會改變如何在VBA Excel中執行SQL查詢
也許你錯過了之前的空格內連接語句 – 2016-09-20 12:57:13
你沒有線之間的空間。 – czuroski
我不是關於spaes,是否需要在'tl'之前放置'AS'。 – Nebi