|
大家好.下面的函数,如果我加上
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
在gridex控件上只显示一条记录.
我不能关闭记录集.要设置哪个参数呢?
'公共的gridEX控件取记录集函数
Public Function pub_GridEX_record(grid As Object, sqlstr As String) '用法:GridEX对象名,SQL语句)
On Error GoTo aa
Dim grobject As GridEX
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Set cn = CurrentProject.Connection
Set grobject = grid.Object
cn.CommandTimeout = 0
rs.CursorLocation = adUseClient
rs.CursorType = adOpenDynamic 'adOpenStatic '
rs.LockType = adLockReadOnly
Set rs = cn.Execute(sqlstr)
Set grobject.ADORecordset = rs
'rs.Close
'Set rs = Nothing
'cn.Close
' Set cn = Nothing
bb:
Exit Function
aa:
MsgBox Err.Description, vbInformation, sysstr
Resume bb
End Function
|
|