sql="select * from a where b=" & num & ""
if rs.state=adstateopen then rs.close
rs.open connection,adopenkeyset,adlockpressimistic
if rs.state=adstateopen then rs.close
rs.open connection,adopenkeyset,adlockpressimistic
dim rs as new adodb.recordset
===========================================
楼主的rs每次都是重新定义,应该不会报告“rs打开不容许操作”Private Sub Combo1_Click()
Dim rs As New Recordset
rs.Open "select * from 五笔 where 编码='" & Combo1.Text & "'", cn, adOpenKeyset, adLockPessimistic, adCmdText
Set DataGrid1.DataSource = rs
End Sub
这样的代码不报错除非楼主的rs其实是一个全局对象,那就可能会报错了,按照Leftie的方法就可以解决
sql="select * from a where b='"& num &"'
试试看!!!!