简体   繁体   English

VBA中SQL查询表达式中的运行时错误'-2147217900(80040e14)'语法错误(缺少运算符)

[英]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: 我正在VBA中构建SQL查询,并且以下返回错误:

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

Debug.Print stSQLstring gives: Debug.Print stSQLstring提供:

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). 然后,我使用ACE.OLEDB来查询一个外部工作簿(我认为这一部分很好,因为它可以与其他SQL语句一起使用,而不是与之对应)。

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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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