我想在Excel宏中的查询中传递FOR语句的迭代:
For i=1 To 9
For j=1 To 3
Set rs = conn.Execute("SELECT * FROM TABLE_A WHERE ref1='i' AND ref2='j'")
...
Next j
Next i
我收到此错误: “将数据类型varchar转换为bigint时出错”
在数据库中,ref1和ref2的值是float。
如何正确插入参数?
答案 0 :(得分:0)
您必须连结i
和j
的值。
For i=1 To 9
For j=1 To 3
Set rs = conn.Execute("SELECT * FROM TABLE_A WHERE ref1='" & i & "' AND ref2='" & j & "'")
...
Next j
Next i