aqlstr = "select name,pwd from pwd where name=" ' " & name & "'"
'MsgBox "无此姓名", "登录"
MsgBox "无此姓名",48,"登录"

解决方案 »

  1.   

    Verify = False
    aa = Verify(Text1.Text, Text2.Text)
    ???Verify 到底是函数还是变量?
      

  2.   

    aqlstr = "select name,pwd from pwd where name='" & name & "'"
      

  3.   

    zw_yu(鱼猫) :Verify 是函数
      

  4.   

    Cooly(苦力) 大个应该是对的吧
    或MsgBox  "无此姓名", ,"登录"
      

  5.   

    Verify是函数,但是函数可以返回值的嘛。
    Verify=False是设置函数的返回值。
    aa = Verify(Text1.Text, Text2.Text)是调用函数噻。意思是让aa=调用函数过后的返回值。也就是TRUE OR FALSE
      

  6.   

    Cooly(苦力) 兄的不行,还是出现原来的错误.
      

  7.   

    运行后是此句出错,Set idinfo = Data1.Recordset.OpenRecordset(sqlstr, dbOpenSnapshot, dbReadOnly) 
    编译错误:错误的参数号或无效的属性赋值
    请各位老大相助,谢谢!
      

  8.   

    仔细看看OpenRecordset的参数吧,我好像记得是四个参数的或者是参数的类型不对!!!!
      

  9.   

    aqlstr = "select name,pwd from pwd where name=" & "'" & name & "'"
      

  10.   

    代码如下:
     Public Function Verify(name As String, pwd As String) As Boolean
    data1.recordset.findfirst "name=" & "'" & name & "'"
    if  nomatch then
       msgbox "用户名错误。"
       Verify=false
    else
       if data1.recordset.fields(pwd)<>pwd then
             msgbox "口令错误."
             Verify=false
       else
             verify=true
       end if  
    end if
    End Function
      

  11.   

    aqlstr = "select name,pwd from pwd where name=" '&name&'""

    aqlstr = "select name,pwd from pwd where name='" & name &"'"
      

  12.   

    aqlstr = "select name,pwd from pwd where name='" & name & "'"
    这样就对了。!!
      

  13.   

    Set idinfo = Data1.Recordset.OpenRecordset(sqlstr, dbOpenSnapshot, dbReadOnly) '运行后错误所在
    这里多使用了一个参数,改为:
    Set idinfo = Data1.Recordset.OpenRecordset(sqlstr, dbOpenSnapshot) '运行后错误所在
      

  14.   

    ForrestSun(佑佑) 兄:还是错误
    Set idinfo = Data1.Recordset.OpenRecordset(sqlstr, dbOpenSnapshot) 
    错误代码:数据类型转换错误
    望明示谢谢!
      

  15.   


     Public Function Verify(name As String, pwd As String) As BooleanDim sqlstr As StringData1.Recordset.FindFirst "姓名='" & name & "'"If Data1.Recordset.NoMatch = True Then
      MsgBox "无此姓名", "登录"
      Verify = False
    Else
       If (Data1.Recordset.Fields("口令").Value = pwd) Then
           Verify = True
       Else
           MsgBox "无效密码", , "登录"
           Verify = False
       End If
    End IfEnd FunctionPrivate Sub Command1_Click()
    Dim aa As Boolean
    Dim name As String
    Dim pwd As String
    name = "a"
    pwd = "123"
    aa = Verify(name, pwd)
    End SubPrivate Sub Form_Load()
      Data1.DatabaseName = "c:\a.mdb"
      Data1.RecordSource = "口令表"
    End Sub
    测试通过
      

  16.   

    不过还是建议你使用ADO
    不要再这么绑定到数据控件了
    太累
    而且没法进行模块化管理
      

  17.   

    Public Function Verify(name As String, pwd As String) As Boolean
    Dim idinfo As Recordset
    Dim sqlstr As String
    aqlstr = "select name,pwd from pwd where name='" & name & "'"
    data1.recordsource=sqlstr
    data1.refresh
    If (if data1.recordset.RecordCount = 0) Then
      MsgBox "无此姓名", "登录"
      Verify = False
    Else
       If (idinfo.Fields("pwd").Value = pwd) Then
           Verify = True
       Else
           MsgBox "无效密码",48,"登录"
           Verify = False
       End If
    End If
    set data1.recordset=nothing
    End Function
      

  18.   

    呵呵你也不用他的idinfo了:)
      

  19.   

    我个人认为是这句错了,(aqlstr = "select name,pwd from pwd where name=" '&name&'""
    ),我想应该是:   aqlstr = "select name,pwd from pwd where name= ' " &name & " ' "
      

  20.   

    对不起,写错了,重发
    我个人认为是这句错了:aqlstr = "select name,pwd from pwd where name=" '&name&'""
    ,我想应该是:   aqlstr = "select name,pwd from pwd where name= ' " & name & " ' "
      

  21.   

    aqlstr = "select name,pwd from pwd where name='" & name & "'"
    最少 这一句一定要这样写才对呀。
      

  22.   

    aqlstr = "select name,pwd from pwd where name=" '&name&'""

    aqlstr = "select name,pwd from pwd where name='" & name &"'"
    仔细检查一下,参数对否
    Set idinfo = Data1.Recordset.OpenRecordset(sqlstr, dbOpenSnapshot, dbReadOnly) '运行后错误所在
    再看看连接有没有问题
    建议引用ADO
      

  23.   

    谢谢各位大虾,尤其是ForrestSun(佑佑)兄.各位,小分不成敬意,望各位收下.结帖.(又说废话)
      

  24.   

    晕,少改了一个地方呀!!!:“:”Public Function Verify(name As String, pwd As String) As Boolean
    Dim idinfo As Recordset
    Dim sqlstr As String
    aqlstr = "select name,pwd from pwd where name='" & name & "'"
    data1.recordsource=sqlstr
    data1.refresh
    If (if data1.recordset.RecordCount = 0) Then
      MsgBox "无此姓名",48,"登录"
      Verify = False
    Else
       If (data1.recordset.Fields("pwd").Value = pwd) Then
           Verify = True
       Else
           MsgBox "无效密码",48,"登录"
           Verify = False
       End If
    End If
    set data1.recordset=nothing
    End Function这下应对了