Hi tumtoo10,
Try This:-
Public Function GetStoredProcRS(vConnection, sStoredProcName As String) As ADODB.Recordset
'---------------------------------------------------------'
' Purpose: - Executes Stored Procedure.
'
' Notes: - Returns ADO Recordset if Completed Successfully
'
' The returned Recordset object is always a read-only, forward-only cursor.
' If you need a Recordset object with more functionality, first create a
' Recordset object with the desired property settings, then use the Recordset
' object's Open method to execute the query and return the desired cursor type.
'
'----------------------------------------------------------
'Declare ADO Objects
Dim oCmd As ADODB.Command
Dim oRec As ADODB.Recordset
'Instantiate ADO Objects
Set oRec = New ADODB.Recordset
Set oCmd = New ADODB.Command
With oCmd
'Set the connection to use for this command
.ActiveConnection = vConnection
' Set the properties of the command
.CommandType = adCmdStoredProc
.CommandText = sStoredProcName
End With
'Create Recordset - Assign Properties
With oRec
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockOptimistic
.Open oCmd
End With
Set GetStoredProcRS = oRec
'Release References
Set oCmd = Nothing
Set oRec = Nothing
End Function
Regards,
Codefish