quote:以下是引用万泉河在2011-11-13 22:46:48的发言:
有好多种GRID控件可以使用。
我以前很长时间一直用MSHFGRID。
经过万版主的指点,我成功注册了控件,把它放在了画面中,然后执行程序,貌似现在的情况是数据库中的数据已经回来了在Recordset中,想要把recordset绑定到控件的数据源,但是控件上不显示呀,刷新控件也不行,不知道问题出在哪
我的程序:
为了调试,我加了一些msgbox,所有的msgbox都弹出来了,说明这段脚本已经执行到最后了,但是表中还是没有数,是不是控件本身还要设置什么东西呀?
dim comm,name
name="Provider=SQLOLEDB.1;Password=rission;Persist Security Info=True;User ID=sa;Initial Catalog=test;Data Source=307RISSION\WINCC"
set comm=CreateObject("ADODB.Connection")
comm.open name
if err.number>0 then
MsgBox "打开连接错误!"
else
MsgBox"打开连接成功!"
End If
Dim adoRecordset
set adoRecordset=CreateObject("ADODB.Recordset")
adoRecordset.ActiveConnection = comm
adoRecordset.Source = "SELECT*FROM test"
adoRecordset.Open
MsgBox"打开Recordset成功!"
msgbox adoRecordset("number")
adoRecordset.MoveNext
MsgBox adoRecordset("number")
MsgBox"测试读取完毕!"
Dim s
Set s=ScreenItems("grid")
MsgBox"控件准备好"我的画面上的MSHFGRID名字叫grid
s.DataSource = adoRecordset
s.Refresh
MsgBox"控件刷新"
MsgBox"Over"
comm.close
set comm=Nothing