You can always write a stored procedure which can return some value in the form of parameters. This feature to return information from stored procedures in the form of parameters is very useful. But there are few things that you should consider before you try to use this feature. For instance, your provider may not support output parameters like it is not available in Access. Another important thing is that at what point the output parameters are available.
You can use “Output Parameter Availability” custom property of the connection object to check to see which of the options your provider supports. This property returns one of the following three values:
(a) 1 – Output parameters are not supported
(b) 2 – Output parameters are available after the command has been executed
(c) 4 – Output parameters are available only after the recordset has been closed
Here is a simple method that verifies whether your Provider supports output parameters and at what point. This method takes in a connection object as parameter and displays a message box about the availability of the output parameters.
Private Sub CheckAvailabilityOfOutputParams(ByVal oConnection As ADODB.Connection)' Name of the PropertyConst DBPROP_OUTPUTPARAMETERAVAILABILITY As String = "Output Parameter Availability"' Values returned by the provider for the propertyConst DBPROPVAL_OA_NOTSUPPORTED As Long = &H1Const DBPROPVAL_OA_ATEXECUTE As Long = &H2Const DBPROPVAL_OA_ATROWRELEASE As Long = &H4 On Error GoTo ErrorHandler' The time at which output parameter values become available. One of the following:Select Case oConnection.Properties(DBPROP_OUTPUTPARAMETERAVAILABILITY)Case DBPROPVAL_OA_NOTSUPPORTEDMsgBox "Output parameters are not supported"Case DBPROPVAL_OA_ATEXECUTEMsgBox "Output parameters are available immediately after the call to Command.Execute() method"Case DBPROPVAL_OA_ATROWRELEASEMsgBox "Output parameters are available only after the recordset has been closed"End SelectExit SubErrorHandler:' Display error messageMsgBox "Error Number = " & Err.Number & ", Description = " & Err.Description, _vbCritical, "Output Parameter Availability Error"End Sub