我在修改了显示数据的内容后点击退出按钮时提示:实时错误: 3219
在此环境中不允许操作Option ExplicitDim rs As New ADODB.RecordsetPrivate Sub Command1_Click() '显示表中的内容
rs.CursorLocation = adUseClient
rs.CursorLocation = adUseClient
rs.Open "select * from huiyuanxinxi ", conn, adOpenKeyset, adLockPessimistic
MsgBox rs.RecordCount
Set DataGrid1.DataSource = rs
End SubPrivate Sub Command2_Click() '退出
rs.Close '错误出现在这一行
form1.Show
Unload Me
End Sub
在此环境中不允许操作Option ExplicitDim rs As New ADODB.RecordsetPrivate Sub Command1_Click() '显示表中的内容
rs.CursorLocation = adUseClient
rs.CursorLocation = adUseClient
rs.Open "select * from huiyuanxinxi ", conn, adOpenKeyset, adLockPessimistic
MsgBox rs.RecordCount
Set DataGrid1.DataSource = rs
End SubPrivate Sub Command2_Click() '退出
rs.Close '错误出现在这一行
form1.Show
Unload Me
End Sub
'*************
'修改
if rs.state=adStateOpen then
rs.Close
end if
set rs=nothing
'****************
form1.Show
Unload Me
End Sub
'如果不需要保存数据的话
on error resume next
rs.Close
set rs=nothing
form1.Show
Unload Me
End Sub
Private Sub Command2_Click() '退出
'如果需要保存数据的话
on error resume next
rs.updatebatch
rs.Close
set rs=nothing
form1.Show
Unload Me
End Sub