Private Sub Command1_Click()
Dim Rectable As New ADODB.Recordset
If Rectable.State = 1 Then Rectable.Close
Rectable.CursorLocation = adUseClient
Rectable.Open "Select * from passtable where 用户名='" & Text1.Text & "'", Conn, adOpenStatic, adLockBatchOptimistic
If Rectable.RecordCount = 0 Then
MsgBox "不存在此用户!", vbInformation, Me.Caption
times = times + 1
Exit Sub
End If
Rectable.Close
Rectable.Open "Select * from passtable where 用户名='" & Text1.Text & "' and 密码='" & Text2.Text & "'", Conn, adOpenStatic, adLockBatchOptimistic
If Rectable.RecordCount = 0 Then
MsgBox "密码错误!", vbInformation, Me.Caption
times = times + 1
Exit Sub
End If
Rectable.Close
Rectable.Open "Select * from passtable where 权限='admin'", Conn, adOpenStatic, adLockBatchOptimistic
If Rectable.RecordCount = 0 Then
' If Rectable("权限") = "admin" Then
MsgBox "你无权进入"
Else
login.Visible = False
main.Show
' End If
End If
End Sub
这是我写的判断登陆的代码, 请检查权限那一段 进入之后 根本没有判断 无论 权限是否是"admin" 都能进入这是什么原因呢? 请高手帮我改正一下 思路!
Dim Rectable As New ADODB.Recordset
If Rectable.State = 1 Then Rectable.Close
Rectable.CursorLocation = adUseClient
Rectable.Open "Select * from passtable where 用户名='" & Text1.Text & "'", Conn, adOpenStatic, adLockBatchOptimistic
If Rectable.RecordCount = 0 Then
MsgBox "不存在此用户!", vbInformation, Me.Caption
times = times + 1
Exit Sub
End If
Rectable.Close
Rectable.Open "Select * from passtable where 用户名='" & Text1.Text & "' and 密码='" & Text2.Text & "'", Conn, adOpenStatic, adLockBatchOptimistic
If Rectable.RecordCount = 0 Then
MsgBox "密码错误!", vbInformation, Me.Caption
times = times + 1
Exit Sub
End If
Rectable.Close
Rectable.Open "Select * from passtable where 权限='admin'", Conn, adOpenStatic, adLockBatchOptimistic
If Rectable.RecordCount = 0 Then
' If Rectable("权限") = "admin" Then
MsgBox "你无权进入"
Else
login.Visible = False
main.Show
' End If
End If
End Sub
这是我写的判断登陆的代码, 请检查权限那一段 进入之后 根本没有判断 无论 权限是否是"admin" 都能进入这是什么原因呢? 请高手帮我改正一下 思路!
解决方案 »
- 如何让外部窗口透明和不透明之间转换?
- 跪求vb 条码打印系统的源码
- 问大家几个问题,关于ole与word的?
- 新手学VB有些概念上的问题想请教高手?
- 泰山进来看看,关于时间方面的
- 有关打包的问题...9X与2000
- 关于数据库的
- 用vb在一个已经存在的access数据库中,建立表,我想如果已经有一个同名的表,就提示已经存在,应该怎样做
- 有没有人知道WIN2000装了IIS5以后,在输入127.0.0.1后为什么不能启动.ASP,而直接输入计算机名可以呢?我做个一个WIN2000个人版,想做服务器放一些原代码让大家下载!(
- sstab的使用
- 喜忧参半,散分
- 请教:将空格替换成chr(9).但不管是多少个空格都只换成一个chr(9).多谢!
MsgBox "你无权进入" exit sub '这要加个
Else
login.Visible = False
main.Show
' End If
If Rectable.RecordCount = 0 Then
MsgBox "不存在此用户!", vbInformation, Me.Caption
times = times + 1
Exit Sub
End If
If Rectable!密码 <> Text2.Text Then
MsgBox "密码错误!", vbInformation, Me.Caption
times = times + 1
Exit Sub
End If
If Rectable!权限 <> "admin" Then MsgBox "你无权进入"
Else
login.Visible = False
main.Show
' End If
End If因为你第3次查询是检索表中有无权限=Admin的记录,而不是当前用户是否Admin。
另,也用不着多次查询。
这里有问题
权限应该是和操作员表在一起的一个字段吧Select 权限 from passtable where 姓名=***"