Page view counter

These tutorials demonstrate selected features in ASP.NET version 2.0, but they are compatible with later versions of ASP.NET as well. For the current documentation, see the ASP.NET portal on the MSDN Web site.

 

 

   Welcome   |   ASP.NET   |   Web Services   |   Class Browser   
  |   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"
    
VB


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
View Source





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