发布于 2015-05-01 15:35:59
13楼
Dim sSql
Dim oRs
Dim conn
Dim oCom
Dim Con
Dim m
Con="Driver={SQL Server};Server=USER-20150401YP\SQL2005;uid=sa;pwd=sa123;database=yejian"
Set conn=CreateObject("ADODB.Connection")
conn.ConnectionString=Con
conn.CursorLocation=3
conn.Open
sSql="SELECT * FROM INDIV_INFO "
Set oRs=CreateObject("ADODB.Recordset")
Set oCom=CreateObject("ADODB.Command")
Set oCom.ActiveConnection=conn
oCom.CommandType=1
oCom.CommandText=sSql
Set oRs=oCom.Execute
m=oRs.RecordCount
MsgBox m
Dim Grid
Set Grid=ScreenItems("控件1")
MsgBox("3")
'Set Grid.DataSource = objRecordset.Recordset
Set Grid.DataSource = oRs
MsgBox("4")
Grid.Refresh
Set objRecordset = Nothing
objConnection.Close
Set objConnection = Nothing
已经能查到数据表有11条记录,但是加载到dbgrid控件的脚本还有问题,Dim Grid
Set Grid=ScreenItems("控件1")
MsgBox("3")
'Set Grid.DataSource = objRecordset.Recordset
Set Grid.DataSource = oRs
MsgBox("4")
Grid.Refresh
两位斑竹有没有更好的方法实现数据的绑定呀,求指导