代码如下:
Option Explicit Private Sub cmdLogin_Click() Dim objRecordset As ADODB.Recordset
Dim strSQL As String strSQL = "select username from users where usernama='" & Trim(txtUserName.Text) & "'"
Set objRecordset = ExceuteSQL(strSQL) If objRecordset.EOF = True Then
MsgBox "用户名错误"
txtUserName.SetFocus
txtUserName.SelStart = 0
txtUserName.SelLength = Len(txtUserName.Text)
Exit Sub
End If
UserName = objRecordset.Fields(0) strSQL = "select UserName from user where password='" & Trim(txtPassword.Text) & "'"
Set objRecordset = ExceuteSQL(strSQL)
If objRecordset.EOF = True Or UserName <> objRecordset.Fields(0) Then
MsgBox "密码错误"
txtPassword.SetFocus
txtPassword.SelStart = 0
txtPassword.SelLength = Len(txtPassword.Text)
Exit Sub
End If MDIMain.Show
Unload Me
End Sub Private Sub cmdQuit_Click()
Unload Me
End Sub