关于vb中的recordSet问题,谢谢大家帮助一下
private sub a_click()dim rs as new adodb.recordset
dim sql as string
dim num as integer
sql="select * from a where b="+num
rs.open connection,adopenkeyset,adlockpressimistic
datagrid.allowaddnew=false
datagrid.allowupdate=false
datagrid.allowdelete=false
set datagrid.datasource=rs
end sub
a是个combolist 每次选的不同所以num会不同,sql语句的集合也就会不同,但是
每次点击都要从新更新rs,可以总是报rs打开不容许操作,但是我在最后又不能关闭rs,因为关闭以后datagrid数据会没有的 而且我要进行修改更新datagrid所以只能打开着rs,请高手帮忙一下 怎样才能实现每次更新一下rs呢 --------------------编程问答-------------------- sql="select * from a where b=" & num & ""
if rs.state=adstateopen then rs.close
rs.open connection,adopenkeyset,adlockpressimistic --------------------编程问答-------------------- 把取数据的代码对立出来
private rs as recordset
private sub Form_Load()
filldata
end sub
private sub filldata()
dim sql as string
sql= "select * from a"
rs.open connection,adopenkeyset,adlockpressimistic
datagrid.allowaddnew=false
datagrid.allowupdate=false
datagrid.allowdelete=false
set datagrid.datasource=rs
end sub
private sub a_click()
dim num as integer
rs.filter = "b= " & num
end sub --------------------编程问答-------------------- 一楼的方法就好 --------------------编程问答-------------------- 用rs.filter 比较快速 不用每次都重新查找数据库 --------------------编程问答-------------------- 用一楼的方法因该可以
补充:VB , 数据库(包含打印,安装,报表)