Home   |   QuickStart Welcome   |   ASP.NET   |   Web Services   |   How Do I...?   
  |   I want my samples in...      

How Do I...? Common Tasks QuickStart Tutorial

ADO.NET: Get Out Parameters from a Stored Procedure

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 OleDbCommand or SqlCommand objects.

Unlike the sample below, 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.

    workParam = myCommand.Parameters.Add("@CustomerID", SQLDataType.NChar, 5);
    workParam.Value = "CUSTID";

The following sample shows how to use a stored procedure that returns output parameters. The command is executed to create a stored procedure in the Northwind database.

VB OutParamsWithACommand.aspx
Run Sample View Source

Microsoft .NET Framework SDK QuickStart Tutorials Version 2.0
Copyright � 2004 Microsoft Corporation. All rights reserved.