Dim rs As New Recordset        '定义记录集
  Dim conn As New Connection     '定义连接对像
   Dim conStr As String
   conStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=H:\vb练习\myQQ\QQ.mdb;Persist Security Info=False"
   Set rs = New Recordset
   Set conn = New Connection
   conn.ConnectionString = conStr
   conn.Open
   Set rs.ActiveConnection = conn
   rs.CursorLocation = adUseClient       '返回客户端游标
rs.Source = "select qqid from userinfo where qqid= '" & Val(Combo1.Text) & " ' and _ password='" & txtPassword.Text & " '"
rs.Open , , adOpenStatic, adLockOptimistic一运行就提示:表达式中类型不匹配,我怀疑问题出在这一句上:
rs.Source = "select qqid from userinfo where qqid= '" & Val(Combo1.Text) & " ' and _ password='" & txtPassword.Text & " '"
因为我把它换为一个简单的语句:select * from userinfo 就没错了,请问我错在哪里

解决方案 »

  1.   

    看password是什么类型,如果是数字型的,改为password=" & txtPassword.Text
      

  2.   

    如果 qqid 是数值类型,不要用单引号括起来"select qqid from userinfo where qqid= " & Val(Combo1.Text) & " and password='" & txtPassword.Text & "'"
      

  3.   

    估计password你是数字型的,
    必须对txtPassword.Text处理
    rs.Source = "select qqid from userinfo where qqid= '" & Val(Combo1.Text) & " ' and _ password='" & iif(trim(txtPassword)="",0,txtPassword)& " '"
      

  4.   

    "' and " _
     & " password='"
    应该是这样吧
      

  5.   

    rs.Source = "select qqid from userinfo where qqid= '" & Val(Combo1.Text) & " ' and " & _
    " password='" & txtPassword.Text & " '"
    字符串换行连接用 & _ 
      

  6.   

    to: fun911(再战边缘) 数值类型同样可以用单引号的(这个在sql数据库里是没问题的,但是在Access里会产生 "表达式中类型不匹配" 错误)
      

  7.   

    to: faysky2() 
    噢,不好意思,没玩过Access,所以不了解
      

  8.   

    多谢大家了,是的问题解决了,是qqid是数值型的,换成字符型的就没问题了