为什么执行adodc1.refresh时老是出现对象关闭时,不允许操作

来源:百度知道 编辑:UC知道 时间:2024/05/09 09:59:18
Dim d As Integer
d = MsgBox("确定删除成绩!", vbYesNo)
If d = vbYes Then
If Option1.Value = True Then
Adodc1.RecordSource = "delete * from 学生信息 where 姓名='" & Text1.Text & "'"
Adodc1.Refresh
MsgBox ("删除成功!")
ElseIf Option2.Value = True Then
Adodc1.RecordSource = "delete * from 学生信息 where 学号='" & Text1.Text & "'"
Adodc1.Refresh
MsgBox ("删除成功!")
End If

Else
MsgBox ("放弃删除!")
End If

Dim cn As New ADODB.Connection
Dim rsAs New ADODB.Recordset
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="数据库路径";Persist Security Info=False"
cn.Open ConnectionString
rs.Open "select * from 表名", cn, 1, 3

你可以用"MsgBox cn.State"测试一下连接情况