求助 登录窗口 VB6+ACCESS 运行报错
Option Explicit
Dim cnn As ADODB.Connection
Dim i As Integer
Private Sub Form_Load()
'连接Access数据库
Set cnn = New ADODB.Connection
cnn.Provider = "Microsoft.Jet.OLEDB.4.0"
cnn.Open "Data Source=E:\360data\重要数据\桌面\设计\管理员.mdb;"
'检测数据库是否链接成功
If cnn.State = adStateOpen Then
Else
MsgBox "失败,请检查数据库文件", 48, "数据库连接"
End If
i = 3
Label2.Caption = "您还有 " & i & " 次机会"
End Sub
Private Sub Command1_Click()
'检测密码
Dim Textusername As String
Dim Textpassword As String
Dim rs As ADODB.Recordset
Dim strsql As String
Dim temp As String
Textusername = user.Text
Textpassword = password.Text
If i = 1 Then End '限制登陆次数
If Me.user.Text = "" Or Me.password.Text = "" Then
i = i - 1
Label2.Caption = "您还有 " & i & " 次机会"
MsgBox "用户名和密码不能为空", 48, "提示"
Me.user.SetFocus
'账号或密码为空提示检查
Else
Set rs = New ADODB.Recordset
strsql = "select * from 管理员 where ID='" & Textusername & " ' and 密码='" & Textpassword & "'"
rs.Open strsql, cnn, adOpenStatic, adLockReadOnly 'Open table "管理员"
If rs.EOF Then
MsgBox "用户名或密码错误", vbCritical, "提示"
i = i - 1
Label2.Caption = "您还有 " & i & " 次机会"
Me.user = ""
Me.password = ""
Me.user.SetFocus
Else
rs.Close
Set rs = Nothing
cnn.Close
Unload Me
End If
'从数据库检查用户名和密码的正确性
End If
End Sub
Private Sub Command2_Click()
Unload land
'卸载登陆窗体
End Sub
rs.Open strsql, cnn, adOpenStatic, adLockReadOnly报错
但是前面检查数据库连接时确实是已经连接上了呀 我不知道怎么回事了 卡了好几天都没检查出错来 求大神帮忙啊~~~