VB登录窗体,代码纠错

来源:百度知道 编辑:UC知道 时间:2024/06/14 22:52:26
登录窗体,利用adodc控件从access数据库的“用户管理”表检查用户名称和登录密码,两个文本名是txtUserName和txtPassword运行过程有问题,请大家纠错,谢谢!
Option Explicit
Public LoginSucceeded As Boolean

Private Sub cmdCancel_Click()
'设置全局变量为 false
'不提示失败的登录
LoginSucceeded = False
Me.Hide
End Sub

Private Sub cmdOK_Click()
If Trim(txtUserName.Text) = "" Then
MsgBox "用户名不能为空", vbExclamation + vbOKOnly, "提醒"
txtUserName.SetFocus
Exit Sub
End If

If Trim(txtPassword.Text) = "" Then
MsgBox "用户密码不能为空", vbOKOnly, "提醒"
txtPassword.SetFocus
Exit Sub
End If

If Not IsNumeric(txtPassword.Text) Then
MsgBox "密码必须为数字", vbExclamation + vbOKOnly, "提醒"
txtPassword.SelStart = 0
txtPassword.SelLength = Len(txtPassword)
tx

楼上的错了,虽然可以删掉,但不删掉也是正确的,只是没有必要,楼主的问题,应该不在于这个

由于数据库的程序,没有数据库,有很多问题不好直接找出是什么原因,楼主最好将哪一句上面出错和出错的提示标注出来,这样好找

那就简单了
在Adodc1.RecordSource = "````" 之前加
Adodc1.CommandType = adCmdText