7,763
社区成员
发帖
与我相关
我的任务
分享
Private Sub cmdLogin_Click()
Dim objRecordset As ADODB.Recordset
Dim strSQL As String
strSQL = "select UserName from Users where UserName='" & _
Trim(txtUserName.Text) & ""
Set objRecordset = ExecuteSQL(strSQL)
If objRecordset.EOF = True Then
MsgBox "用户名错误!", vbExclamation + vbOKOnly, "警告"
txtUserName.SetFocus
txtUserName.SelStart = 0
txtUserName.SelLength = Len(txtUserName.Text)
Exit Sub
End If
UserName = objRecordset.Fields(0)
strSQL = "select UserName from Users where Password='" & _
Trim(txtPassword.Text) & ""
Set objRecordset = ExecuteSQL(strSQL)
If objRecordset.EOF = True Or UserName <> objRecordset.Fields(0) Then
MsgBox "密码错误!", vbExclamation + vbOKOnly, "警告"
txtPassword.SetFocus
txtPassword.SelStart = 0
txtPassword.SelLength = Len(txtPassword.Text)
Exit Sub
End If
mdiMain.Show
Unload Me
End Sub
If objRecordset.EOF = True Then
If objRecordset.EOF = True Then
显示黄色UserName = 这里提示变量未定义 和是论坛的字体颜色来着,请无视
Private Sub cmdLogin_Click()
Dim objRecordset As ADODB.Recordset
Dim strSQL As String
dim UserName as string
strSQL = "select UserName from Users where UserName='" & _
Trim(txtUserName.Text) & ""
Set objRecordset = ExecuteSQL(strSQL)
If objRecordset.EOF = True Then
MsgBox "用户名错误!", vbExclamation + vbOKOnly, "警告"
txtUserName.SetFocus
txtUserName.SelStart = 0
txtUserName.SelLength = Len(txtUserName.Text)
Exit Sub
End If
UserName = objRecordset.Fields(0)
strSQL = "select UserName from Users where Password='" & _
Trim(txtPassword.Text) & ""
Set objRecordset = ExecuteSQL(strSQL)
If objRecordset.EOF = True Or UserName <> objRecordset.Fields(0) Then
MsgBox "密码错误!", vbExclamation + vbOKOnly, "警告"
txtPassword.SetFocus
txtPassword.SelStart = 0
txtPassword.SelLength = Len(txtPassword.Text)
Exit Sub
End If
mdiMain.Show
Unload Me
End Sub