bradmaunsell
Programmer
I am new to ADP and wonder if stored procedures need to be closed like closing recordset in a "regualar" mdb application. That is, in a regular application, I always close my recordsets with the following two lines of VBA.
rs.close
set rs=nothing
Below is some VBA code I am using to set a (stored procedure) recordset for a form in my new ADP application. This code works fine.
Do I need to close the form recordset to release the resources?
Thanks,
Brad
==========================================================
Public Sub LoadFormRecordset(frm As Form, lngKeyPara As Long, stSP As String)
Dim Param1 As ADODB.Parameter
Dim cmd As ADODB.Command
Dim rs As New ADODB.Recordset
Set Param1 = CreateObject("ADODB.Parameter")
Param1.Direction = adParamInput
Param1.Type = adInteger
Param1.Value = lngKeyPara
Set cmd = New ADODB.Command
cmd.CommandType = adCmdStoredProc
cmd.CommandText = stSP
cmd.Parameters.Append Param1
Set rs = CreateObject("ADODB.Recordset")
rs.CursorLocation = adUseServer 'CursorLocation must be set before setting connection - not affect existing (open connection)
cmd.ActiveConnection = CurrentProject.Connection
Call rs.Open(cmd, , adOpenDynamic, adLockOptimistic)
Set frm.Recordset = rs
End Sub
rs.close
set rs=nothing
Below is some VBA code I am using to set a (stored procedure) recordset for a form in my new ADP application. This code works fine.
Do I need to close the form recordset to release the resources?
Thanks,
Brad
==========================================================
Public Sub LoadFormRecordset(frm As Form, lngKeyPara As Long, stSP As String)
Dim Param1 As ADODB.Parameter
Dim cmd As ADODB.Command
Dim rs As New ADODB.Recordset
Set Param1 = CreateObject("ADODB.Parameter")
Param1.Direction = adParamInput
Param1.Type = adInteger
Param1.Value = lngKeyPara
Set cmd = New ADODB.Command
cmd.CommandType = adCmdStoredProc
cmd.CommandText = stSP
cmd.Parameters.Append Param1
Set rs = CreateObject("ADODB.Recordset")
rs.CursorLocation = adUseServer 'CursorLocation must be set before setting connection - not affect existing (open connection)
cmd.ActiveConnection = CurrentProject.Connection
Call rs.Open(cmd, , adOpenDynamic, adLockOptimistic)
Set frm.Recordset = rs
End Sub