VB做登录窗口 作了Access数据库,在数据库里有ZHANGHAO表 表里有帐号和密码。窗体里添加了一个Adodc1部件
问题是无论输入什么帐号和密码都能登录成功,大神看看哪里的问题DimconnAsNewADODB.Connection:DimrsAsNewADODB.RecordsetP...
问题是无论输入什么帐号和密码 都能登录成功,大神看看哪里的问题
Dim conn As New ADODB.Connection: Dim rs As New ADODB.Recordset
Private Sub Command1_Click()
On Error Resume Next
Dim a As String
Dim b As String
Dim sqlstr As String
Static number As Integer
a = Trim(Text1.Text)
b = Trim(Text2.Text)
If Text1.Text = "" Then
MsgBox "帐户不能为空,请核对帐户信息!!", vbCritical, "核对帐户信息"
ElseIf Text2.Text = "" Then
MsgBox "密码不能为空,请核对密码信息!!", vbCritical, "核对密码信息"
Else
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\lingling\Desktop\毕业设计\VB\tuzhiku.mdb;Persist Security Info=False"
sqlstr = "select * from ZHANGHAO where 用户=" & a & "' and 密码='" & b & "'"
Adodc1.Refresh
If Adodc1.Recordset.EOF Then '登录失败
MsgBox "对不起,无此用户或者密码不正确!请重新输入!!", vbCritical, "错误"
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
number = number + 1
Label3.Caption = "您已经登录了" & number & "次"
If number >= 3 Then
Command1.Enabled = False
Text1.Enabled = False
Text2.Enabled = False
MsgBox "您无权操作本系统,请您退出!", vbCritical, "无权限"
End If
Else '登陆成功
MsgBox "用户审核成功,欢迎使用本系统!!", vbInformation, "审核成功"
Unload Me
mainform.Show
End If
End If
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Form_Load()
sql = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\lingling\Desktop\毕业设计\VB\tuzhiku.mdb;Persist Security Info=False"
End Sub 展开
Dim conn As New ADODB.Connection: Dim rs As New ADODB.Recordset
Private Sub Command1_Click()
On Error Resume Next
Dim a As String
Dim b As String
Dim sqlstr As String
Static number As Integer
a = Trim(Text1.Text)
b = Trim(Text2.Text)
If Text1.Text = "" Then
MsgBox "帐户不能为空,请核对帐户信息!!", vbCritical, "核对帐户信息"
ElseIf Text2.Text = "" Then
MsgBox "密码不能为空,请核对密码信息!!", vbCritical, "核对密码信息"
Else
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\lingling\Desktop\毕业设计\VB\tuzhiku.mdb;Persist Security Info=False"
sqlstr = "select * from ZHANGHAO where 用户=" & a & "' and 密码='" & b & "'"
Adodc1.Refresh
If Adodc1.Recordset.EOF Then '登录失败
MsgBox "对不起,无此用户或者密码不正确!请重新输入!!", vbCritical, "错误"
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
number = number + 1
Label3.Caption = "您已经登录了" & number & "次"
If number >= 3 Then
Command1.Enabled = False
Text1.Enabled = False
Text2.Enabled = False
MsgBox "您无权操作本系统,请您退出!", vbCritical, "无权限"
End If
Else '登陆成功
MsgBox "用户审核成功,欢迎使用本系统!!", vbInformation, "审核成功"
Unload Me
mainform.Show
End If
End If
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Form_Load()
sql = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\lingling\Desktop\毕业设计\VB\tuzhiku.mdb;Persist Security Info=False"
End Sub 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询