Private Sub Command1_Click()
Dim cn As ADODB.Connection
Dim SQL As String
Dim RS As ADODB.Recordset
Set cn = New ADODB.Connection
cn.ConnectionString = " Provider=SQLOLEDB.1;Persist Security Info=True;User ID=sa;Password=sa;Initial Catalog=db_DY;Data Source=NIE" RS.CursorLocation = adUseClient
'   RS.CursorType = adOpenStatic
cn.Open
If Trim(Text1.Text) <> "" Then
    SQL = "SELECT * FROM tb_userinfo WHERE userid='" & Trim(Text1.Text) & "'"
    Set RS = cn.Execute(SQL)
    If RS.RecordCount > 0 Then
      If Text2.Text = RS!pwd Then
        MsgBox "登录成功!"
      End If
    Else
      MsgBox "登录名错误,请确认"
      Text1.Text = " "
    End If
Else
    MsgBox "请输入用户名"
End If
cn.Close
Set cn = Nothing
End Sub