MS SQL Server
  Home arrow MS SQL Server arrow Page 2 - Working with NULL, OUTPUT and RETURN in AD...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
MS SQL SERVER

Working with NULL, OUTPUT and RETURN in ADO.NET
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 13
    2006-04-18

    Table of Contents:
  • Working with NULL, OUTPUT and RETURN in ADO.NET
  • How to work with an OUTPUT parameter of a stored procedure using ADO.NET from ASP.NET: stored procedure
  • How to work with an OUTPUT parameter of a stored procedure using ADO.NET from ASP.NET: the code
  • How to retrieve the value returned by a stored procedure using ADO.NET from ASP.NET: the stored procedure

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Working with NULL, OUTPUT and RETURN in ADO.NET - How to work with an OUTPUT parameter of a stored procedure using ADO.NET from ASP.NET: stored procedure


    (Page 2 of 4 )

    What is an OUTPUT parameter really?  We generally use a parameter to send a value into the stored procedure.  The OUTPUT parameter of a stored procedure helps us send a value back to the calling environment (in this case, it would be ADO.NET) from within the stored procedure. 

    The matter can be simplified as follows:

    INPUT parameter – value gets passed from the calling environment (ADO.NET) to the stored procedure.

    OUTPUT parameter – value gets passed from the stored procedure to the calling environment (ADO.NET).

    Before going to the ADO.NET code, we need to create a simple stored procedure in SQL Server with a simple OUTPUT parameter.  Using “Query Analyzer,” execute the following script in the “Northwind” database.

    CREATE PROCEDURE dbo.sp_emp_getEname
          (
                @empno int,
                @name varchar(20) OUTPUT
          )
    AS
          SELECT @name = ename FROM emp
                WHERE empno=@empno
          RETURN

    The above stored procedure simply retrieves a row from the “emp” table based on the “empno” we provide.  The “ename” is retrieved and placed in our OUTPUT parameter “@name” (which can be used in our web form). The stored procedure is named “sp_Emp_getEname.”  Now we need to use ADO.NET to access the same in ASP.NET (proceed to the next section).

    More MS SQL Server Articles
    More By Jagadish Chaterjee


       · Hello guys. This is second in series focusing on "Working with Stored Procedures...
       · i really liked article on working with out parameter of stored procedure....this...
     

    MS SQL SERVER ARTICLES

    - Completing the Introduction to Transact-SQL
    - A Brief Introduction to Transact-SQL
    - Lookups and Blocking Bad Data
    - Field Validation Rules for Blocking Bad Data
    - Using Masks to Block Bad Data
    - Blocking Bad Data
    - Using @@ROWCOUNT and TABLE Variables for Dat...
    - How to Use Variables, IF and CASE in Databas...
    - Creating Important Aspects of Notification S...
    - Working wth Variables in Database Interactio...
    - Delving Deeper into Notification Services
    - Notification Services
    - Building a Multi-table Report with SQL 2005 ...
    - A Secure Way of Building Connection Strings
    - Transferring a Database Using the SSIS Desig...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
    Stay green...Green IT