我这段程序总是出错,能不能帮我看看??谢谢啦~我是新来的不太懂 呵呵

LIU891666 2010-10-20 11:07:25
先谢谢各位大侠啦~~~我们老师让交的作业,我怎么都弄不对,求您快帮我看看吧。。。跪谢
希望您帮我指出错误,还能告诉我解决方法。。。。谢谢啦~~~

Private Sub cmdOk_Click()
Static intLogTimes As Integer
intLogTimes = intLogTimes + 1
If intLogTimes > MaxLogTimes Then
MsgBox "你已经超过允许的登录验证次数!" & vbCr _
& "应用程序将结束!", vbCritical, "登录验证"
End
Else
Select Case Check_PassWord()
Case 0
MsgBox txtLog(0) & "不是系统用户," _
& "请检查用户名输入是否正确!", _
vbCritical, "登录验证"
txtLog(0).SetFocus
txtLog(0).SelStart = 0
txtLog(0).SelLength = Len(txtLog(0))
Case 1
MsgBox "口令错误,请重新输入!", vbCritical, "登录验证"
txtLog(1) = ""
txtLog(1).SetFocus
Case 2
Unload Me
MsgBox "登录成功,将启动系统管理程序!", _
vbInformation, "登录验证"
frmSysMain.Show
Case Else
MsgBox "登录验证未正常完成!请重新运行登录程序," _
& vbCrLf & "如果仍不能登录,请报告系统管理员!", _
vbCritical, "登录验证"
End Select
End If
End Sub



Private Function Check_PassWord() As Byte
On Error GoTo gpError
Dim objCn As New Connection, objRs As New Recordset
Dim strCn As String, strSQL As String
strCn = "Provider=MSDASQL.1;Persist Security Info = False;" & _
"Data Source=物管数据 DSN"
objCn.ConnectionString = strCn
objCn.ConnectionTimeout = 30
objCn.Open
strSQL = "SELECT*FROM 系统用户 WHERE 用户名=""& txtLog(0)&"
Set objRs.ActiveConnection = objCn
objRs.Open (strSQL)
If objRs.EOF Then
Check_PassWord = 0
Else
If txtLog(1) <> Trim(objRs.Fields("口令")) Then
Check_PassWord = 1
Else
Check_PassWord = 2
CurrentUserName = objRs.Fields("用户名").Value
CurrentUserPassWord = objRs.Fields("口令").Value
CurrentUserStatus = objRs.Fields("身份").Value
End If
End If
objCn.Close
Set objRs = Nothing
Set objCn = Nothing
Exit Function
gpError
Check_PassWord = 255
End Function



Private Sub cmdCancel_Click()
If MsgBox("你选择了退出系统登录,退出将不能启动管理系统!" & vbCrLf _
& "是否真的退出?", vbYesNo, "登录验证") = vbYes Then
Unload Me
End If
End Sub




Private Sub Form_Load()
Const MaxLogTimes As Integer = 3

End Sub
...全文
47 点赞 收藏 3
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
of123 2010-10-21
strSQL = "SELECT * FROM 系统用户 WHERE 用户名= '"& txtLog(0)& "'"
回复
饮水需思源 2010-10-21
1,SQL语句的关键字之间加要空格
2,字符型变量的引用方法:用户名='"& 变量名 &"'
strSQL = "SELECT * FROM 系统用户 WHERE 用户名='"& txtLog(0)&"'"

回复
相关推荐
发帖

1188

社区成员

VB 数据库(包含打印,安装,报表)
申请成为版主
帖子事件
创建了帖子
2010-10-20 11:07
社区公告
暂无公告