作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
下面是我的代码的摘录。
这是 SQL 命令:
vSQL = "SELECT OLIN.fk_cCUST as CustomerKey, Sum(nOLINselTota) AS ResultSumV "
vSQL = vSQL & " FROM (OLIN Inner Join TYOR on OLIN.fk_cTYOR = TYOR.cTYOR) INNER Join MTYP On TYOR.fk_cMTYP = MTYP.cMTYP "
vSQL = vSQL & " Where OLIN.fk_cOHEAkey Like 'T180*' "
vSQL = vSQL & " GROUP BY OLIN.fk_cCUST "
vSQL = vSQL & ";"
vDataSRC = "C:\_projCuTOPs\bdd\GSF_dataWHouse.accdb"
vArrSRC = "OLEDB;Provider=Microsoft.ACE.OLEDB.12.0;Password="""";User ID=Admin;"
vArrSRC = vArrSRC & "Data Source= " & vDataSRC & ";"
vArrSRC = vArrSRC & "Mode=Share Deny Write;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";"
vArrSRC = vArrSRC & "Jet OLEDB:Engine Type=6;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;"
vArrSRC = vArrSRC & "Jet OLEDB:New Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;"
vArrSRC = vArrSRC & "Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False;Jet OLEDB:Support Complex Data=False;Jet OLEDB:Bypass UserInfo Validation=False;"
vArrSRC = vArrSRC & "Jet OLEDB:Limited DB Caching=False;Jet OLEDB:Bypass ChoiceField Validation=False"
ActiveWorkbook.Sheets.Add After:=Worksheets(Worksheets.Count)
ActiveWorkbook.Sheets(Worksheets.Count).Name = "RawDatas"
With ActiveSheet.ListObjects.Add(SourceType:=xlSrcExternal, Source:=vArrSRC, Destination:=Range("$A$1")).QueryTable
'>>
.CommandType = xlCmdSql
.CommandText = vSQL
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
'**
.SourceDataFile = vDataSRC
'**
.ListObject.DisplayName = "tbl_SQL_SumTYOR"
.Refresh BackgroundQuery:=False
'>>
End With
最佳答案
LIKE
在 MS Access GUI(前端)和与 MS Access(后端)的任何 ODBC/OLDEB 连接之间运行查询时,通配符的行为不同。参见 MSDN docs 中 ANSI-89 和 ANSI-92 之间的区别.
对于您在 Excel 中所做的 ODBC/OLEDB 连接,LIKE
需要带有 %
的 ANSI-92 通配符:
vSQL = vSQL & " Where OLIN.fk_cOHEAkey Like 'T180%' "
ALIKE
GUI 和 ODBC/OLEDB 中的(类 ANSI):
vSQL = vSQL & " Where OLIN.fk_cOHEAkey ALike 'T180%' "
SELECT OLIN.fk_cCUST as CustomerKey,
SUM(nOLINselTota) AS ResultSumV
FROM (OLIN INNER JOIN TYOR ON OLIN.fk_cTYOR = TYOR.cTYOR)
INNER Join MTYP On TYOR.fk_cMTYP = MTYP.cMTYP
WHERE OLIN.fk_cOHEAkey LIKE 'T180*'
GROUP BY OLIN.fk_cCUST
vSQL = "SELECT * FROM mySavedQuery"
关于sql - 带有 SQL : No row returned when Where clause specified 的 Excel VBA,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53855368/
我是一名优秀的程序员,十分优秀!