主题:[讨论]vb+access 问题 望高手解决
公共模块中:Public Con As New ADODB.Connection
Public Rs As New ADODB.Recordset
Sub main()
Con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\gr.db1.mdb;Persist Security Info=False"
frmLogin.Show
End Sub
窗体中:Private Sub cmdOK_Click()
If text2.Text = "" Then '对用户名及密码进行判断
MsgBox "用户名或密码不可为空!"
Exit Sub
End If
If Rs.State = 1 Then '如果数据已经打开则关闭
Rs.Close
End If
' 通过在数据库中查找到的用户名及密码还有权限来确定用户登陆的窗体
Rs.Open "select * from fuser where fpw = '" & text2.Text & "' and fpd='" & Combo1.Text & "'", Con, adOpenDynamic, adLockOptimistic
If Rs.EOF = True Then
MsgBox "您的身份不正确!"
Exit Sub
End If
If Combo1.Text = "普通用户" Then
MDIForm1.Show
frmLogin.Hide
ElseIf Combo1.Text = "管理员" Then
MDIForm1.Show
frmLogin.Hide
End If
End Sub
为什么提示Rs.Open "select * from fuser where fpw = '" & text2.Text & "' and fpd='" & Combo1.Text & "'", Con, adOpenDynamic, adLockOptimistic
实时错误'3709' 连接无法用于执行此操作。在此上下文中他可能已被关闭或无效。
希望高手们 给予解决 谢了!
Public Rs As New ADODB.Recordset
Sub main()
Con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\gr.db1.mdb;Persist Security Info=False"
frmLogin.Show
End Sub
窗体中:Private Sub cmdOK_Click()
If text2.Text = "" Then '对用户名及密码进行判断
MsgBox "用户名或密码不可为空!"
Exit Sub
End If
If Rs.State = 1 Then '如果数据已经打开则关闭
Rs.Close
End If
' 通过在数据库中查找到的用户名及密码还有权限来确定用户登陆的窗体
Rs.Open "select * from fuser where fpw = '" & text2.Text & "' and fpd='" & Combo1.Text & "'", Con, adOpenDynamic, adLockOptimistic
If Rs.EOF = True Then
MsgBox "您的身份不正确!"
Exit Sub
End If
If Combo1.Text = "普通用户" Then
MDIForm1.Show
frmLogin.Hide
ElseIf Combo1.Text = "管理员" Then
MDIForm1.Show
frmLogin.Hide
End If
End Sub
为什么提示Rs.Open "select * from fuser where fpw = '" & text2.Text & "' and fpd='" & Combo1.Text & "'", Con, adOpenDynamic, adLockOptimistic
实时错误'3709' 连接无法用于执行此操作。在此上下文中他可能已被关闭或无效。
希望高手们 给予解决 谢了!