Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Enterprise
Expertise: Intermediate
Sep 8, 1999

Check if Provider Supports Output Parameters from Stored Procedures

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 Property
Const DBPROP_OUTPUTPARAMETERAVAILABILITY As String = "Output Parameter Availability"
' Values returned by the provider for the property
Const DBPROPVAL_OA_NOTSUPPORTED As Long = &H1
Const DBPROPVAL_OA_ATEXECUTE As Long = &H2
Const 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_NOTSUPPORTED
MsgBox "Output parameters are not supported"
Case DBPROPVAL_OA_ATEXECUTE
MsgBox "Output parameters are available immediately after the call to Command.Execute() method"
Case DBPROPVAL_OA_ATROWRELEASE
MsgBox "Output parameters are available only after the recordset has been closed"
End Select
Exit Sub
ErrorHandler:
' Display error message
MsgBox "Error Number = " & Err.Number & ", Description = " & Err.Description, _
vbCritical, "Output Parameter Availability Error"
End Sub 
Deepak Pant
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date