-1

我将变量传递给 SQL 查询。

Dim accept As String
accept = Cursor1.GetString("accepted_id")
    Msgbox(accept, "")  
    Cursor1 = SQL1.ExecQuery("SELECT answer FROM answers WHERE accepted_id =" & " 'accept' " )

还有更多代码,但这应该足够了。没有错误,并且 msgbox 显示正确答案。一切看起来都不错,但它没有检索到任何结果。

如果我硬编码答案而不是它的变量,例如,

 Dim accept As String
    accept = Cursor1.GetString("accepted_id")
        Msgbox(accept, "")  
        Cursor1 = SQL1.ExecQuery("SELECT answer FROM answers WHERE accepted_id =" & " 'CD6028' " )

msgbox 显示 CD6028。

结果显示在列表视图中,但什么也没有。

4

1 回答 1

2

似乎您正在将文字字符串传递accept给变量而不是变量accept本身。

替换这个:

Cursor1 = SQL1.ExecQuery("SELECT answer FROM answers WHERE accepted_id =" & " 'accept' " )

和 :

Cursor1 = SQL1.ExecQuery("SELECT answer FROM answers WHERE accepted_id = '" & accept & "'")
于 2019-01-21T02:11:43.353 回答