简体   繁体   中英

Run-time error '-2147217900 (80040e14)' sytax error (missing operatory) in SQL query expression in VBA

I am building SQL queries in VBA, and the following returns an error:

stSQLstring = "SELECT * FROM [" & sheetName & "$]
               WHERE [" & headerName & "] in (" & stNodes & ");"

Debug.Print stSQLstring gives:

SELECT * FROM [sheetName$]
WHERE [headerName] in ('3','4','5','6','16','45','64','65','67','71','76','79','80','86','89','103','115','116','124','142','145','160');

I am then using ACE.OLEDB to query an external workbook (I think this part is fine as it works with other SQL statements, just not this one).

I would be really grateful for you help!

处理数字时,请勿使用单引号。

SELECT * FROM [sheetName$] WHERE [headerName] in (3,4,5,6,16,45,64,65,67,71,76,79,80,86,89,103,115,116,124,142,145,160);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM