用下列语句进行数据库连接的时候,总是不能成功读取出信息
如:s = 001
   rs.Open "select * from table where id = 's' "
但是当直接输入相应的id进行查询时,可以得到正确的结果
如:rs.Open "select * from table where id = '001' "请问在进行参数传递的时候到底是怎么样的格式.

解决方案 »

  1.   

    s是什么?变量吗?要是变量应该是 rs.Open "select * from table where id = '"& s & "'"
      

  2.   

    's为字符型变量则:rs.Open "select * from table where id = '" & s & "' "
    's为数值型变量则:rs.Open "select * from table where id = " & s & " "
      

  3.   

    rs.Open "select * from table where id = 's' "
    你写得这个's'好像是一个单纯的字符啊,意思是在数据中找id=s的记录,而你的意思是找id=001的吧,应该写成:rs.Open "select * from table where id = '"& s & "'"