'vsflexgrid获取数据源
Function VSFGridAdd(SqlText As String, vsfg As Object) As Recordset
Dim cn As New ADODB.Connection
If cn.State = adStateOpen Then cn.Close
cn.ConnectionString = ConnectString
cn.Open
cn.CursorLocation = adUseClient
'使用客户端游标
Dim MyComm As New
'定义一个命令对象
Dim param As ADODB.Parameter
'定义一个参数对象
Set VSFGridAdd = New ADODB.Recordset
With MyComm
.ActiveConnection = cn
'数据连接
.CommandType = adCmdText
'调用SQL 查询语言
.Prepared = True
'要求将SQL命令先行编译
.CommandText = SqlText
End With
If TypeOf vsfg Is VSFlexGrid Then
vsfg.VirtualData = False
'如果为true,只能显示前100条记录
Set vsfg.DataSource = MyComm.Execute()
Else
Set VSFGridAdd = MyComm.Execute()
' 执行此存储过程,返回记录集
End If
End Function