调用过程后显示数据问题

aigozer 2008-04-06 09:19:14
Private Sub Command1_Click()
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim cmd As New ADODB.Command
con.Open "Provider=Sybase.ASEOLEDBProvider.2;Initial Catalog=bok;Password=***;User ID=sa;Data Source=bokado;Persist Security Info=True"
Set cmd.ActiveConnection = con
cmd.CommandType = adCmdText

cmd.CommandType = adCmdStoredProc
cmd.CommandText = "z_member_update_mx"
cmd.Parameters("@d1") = DTPicker1.Value
cmd.Parameters("@d2") = DTPicker2.Value
cmd.Execute
Set rs = cmd.Execute
Set MSHFlexGrid1.DataSource = rs
End Sub
我想当rs.recount>0时,才在mshflexgrid中显示数据,rs.recount为0时,显示msgbox信息,同时清掉mshflexgrid中之前的数据

如何修改上面代码
...全文
64 点赞 收藏 4
写回复
4 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
vbman2003 2008-04-08
if rs.bof and rs.eof then
MSHFlexGrid1.clear
msgbox "rs.bof and rs.eof "
else
Set MSHFlexGrid1.DataSource = rs
end if
回复
w123wxh 2008-04-08
if rs.recount>0 then
Set MSHFlexGrid1.DataSource = rs
else
MSHFlexGrid1.clear
msgbox ""
edif
回复
aigozer 2008-04-08
Set rs = cmd.Execute
If rs.RecordCount Then
Set MSHFlexGrid1.DataSource = rs
else
mshflexgrid1.clear
end if

这样写后,查不出任何数据

原本这样写是可查出数据的
Set rs = cmd.Execute
Set MSHFlexGrid1.DataSource = rs
回复
bleach210 2008-04-06
新手,学习。
回复
相关推荐
发帖
VB基础类
创建于2007-09-28

7490

社区成员

VB 基础类
申请成为版主
帖子事件
创建了帖子
2008-04-06 09:19
社区公告
暂无公告