Click here to Skip to main content
15,886,067 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
How to Retrieve Stored Procedure Output Parameters in only mvc 4 give me code plz.............................................................................
Posted
Updated 15-Nov-13 8:05am
v2
Comments
Sampath Lokuge 15-Nov-13 12:41pm    
Are you using EF ?
Member 8031915 15-Nov-13 16:28pm    
no. i m using data access layer and business layer with mvc 4 not use entity framework

1 solution

You can write the SP is as below :

SQL
CREATE PROCEDURE [dbo].[GetDepartmentName]
      @ID int,
      @Name nvarchar(50) OUTPUT
      AS
      SELECT @Name = Name FROM Department
      WHERE DepartmentID = @ID


For more info : MSDN

If you're using EF then check below mentioned articles.

using (MyEntities myContext = new MyEntities ())            
{                
   System.Data.Objects.ObjectParameter output = new System.Data.Objects.ObjectParameter("OutputParameterName", typeof(int));                
   myContext.GetCustomerCount(output);                
   Console.WriteLine(output.Value);            
}


More info : Output parameter with Entity Framework

Another one : How to Retrieve Stored Procedure Output Parameters in Entity Framework
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900