vb中对象打开时,不能操作,急急急!!!

来源:百度知道 编辑:UC知道 时间:2024/09/20 16:34:22
模块中定义内容:
Public UserStyle As String
Public str As String
Public userID As String
Public adors As New ADODB.Recordset
Public adoconn As New ADODB.Connection
Sub opendata()
If adoconnstate = adStateOpen Then
adonconn.Close
End If
str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + App.Path + "\exam.mdb;Persist Security Info=False"
adoconn.Open str
End Sub

用户登录有三种类型,不同类型的用户ID和密码,保存在不同的表里
登录验证代码如下:
Private Sub yes_Click()
Dim password As String
Dim Conn As String
Call opendata
userID = Trim(TextLogin(0).Text)
password = Trim(TextLogin(1).Text)
If UserStyle = "学生" Then
Conn = " select number,password from student where name='" & userID & "'"
ElseIf UserStyle = "教师" Then
Conn = " select number,password from teacher where name='

Sub opendata()
If adoconnstate = adStateOpen Then
adonconn.Close
End If
str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + App.Path + "\exam.mdb;Persist Security Info=False"
adoconn.Open str
End Sub
你这段代码有问题啊
写错好多东西。我给修改了。你看看
Sub opendata()
If adoconn.State = adStateOpen Then
adoconn.Close
End If
str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + App.Path + "\exam.mdb;Persist Security Info=False"
adoconn.Open str
End Sub

你看你贴出来的代码中adoconn.State 是一处,adonconn是又一处。我改完的我已测试通过。