<h4>ADO+:Getting Out Parameters from a Stored Procedure</h4>
<hr>
<p>
Some stored procedures return values through parameters. When a parameter in a SQL statement or stored procedure is declared as "out", the value of the parameter is returned back to the caller; the value is stored in a parameter in the Parameters collection on the ADOCommand or SQLCommand objects.
<p>
In order to effectively use the parameters collection, set the CommandText property on the SQLCommand, and give it a Connection. This can be done in the constructor:
<p>
<div class=code>
SQLCommand myCommand = new SQLCommand("GetCompanyName", myConnection);
</div>
<p>
Once the SQLConnection and CommandText are set, the parameters collection is filled. (In fact it is filled the first time you access it.) You can access the parameters' names, types and values. Setting the value of the parameter binds that value to the parameter and passes it to the database, if and when the SQLCommand is executed.
If the connection and command name are not set, you can still establish the parameters, but you have to create the collection of parameters and expected types.
The sample below shows using a stored procedure that returns a stored procedure. The command is executed to create a stored procedure in the Northwind database.