程序结构不对,应该做个循环,把表中的纪录遍历,当有和text1.text相同的纪录时停下,并判断密码是否相同。
例如rs.movefirst
while Not rs.eof
if text1.text=rs.fileds("用户名") and text2.text=rs.fields("密码") then
                                                                    Me.Hide
                                                                    Form2.Show
                                                                    MsgBox "欢迎进入本系统", , "Welcome"
                                                                                               
end if
rs.movenext
wend或者直接写sql语句rs.open"select * from 表 where 用户名=“&text1.text&"and 密码="&text2.text再根据rs是否为空来判断
  

解决方案 »

  1.   

    dim d as new adodb.recordset
    d.open "select * from TUser where FName='" & text1.text & "' and FPassword='" & text2.text & "'"
    if d.eof and d.bof then
        msgbox "用户名不存在或密码错误"
    else
       me.hide
       ....
    endif
      

  2.   

    程序改为Option Explicit
    Dim conn As ADODB.ConnectionPrivate Sub Form_Load()
        Set conn = New ADODB.Connection
        With conn
            .ConnectionString = "provider=MSDASQL;dsn=ptty"
            .CursorLocation = adUseClient
            .Open
        End With
    End SubPrivate Sub Command1_Click()
    dim d as new adodb.recordset
    d.open "select * from TUser where FName='" & text1.text & "' and FPassword='" & text2.text & "'"
    if d.eof and d.bof then
        msgbox "用户名不存在或密码错误"
    else
      me.hide
      form2.show
    endif
    end sub运行后 command1.click  报实时错误 '3709'
    在一个已关闭的或无效连接的对象参照上操作不被允许.
      

  3.   

    d.open "select * from TUser where FName='" & text1.text & "' and FPassword='" & text2.text & "'"
    改为:
    d.open "select * from TUser where FName='" & text1.text & "' and FPassword='" & text2.text & "'",conn