Click here to Skip to main content
15,910,773 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
If the procedure is returning explicitly the error code and using OUTPUT
parameter how to access both.like below example which i have taken from microsoft site.
SQL
USE Northwind
GO
-- Create a procedure that takes one input parameter
-- and returns one output parameter and a return code.
CREATE PROCEDURE SampleProcedure @EmployeeIDParm INT,
         @MaxQuantity INT OUTPUT
AS
-- Declare and initialize a variable to hold @@ERROR.
DECLARE @ErrorSave INT
SET @ErrorSave = 0

-- Do a SELECT using the input parameter.
SELECT FirstName, LastName, Title
FROM Employees
WHERE EmployeeID = @EmployeeIDParm

-- Save any nonzero @@ERROR value.
IF (@@ERROR <> 0)
   SET @ErrorSave = @@ERROR

-- Set a value in the output parameter.
SELECT @MaxQuantity = MAX(Quantity)
FROM [Order Details]

IF (@@ERROR <> 0)
   SET @ErrorSave = @@ERROR

-- Returns 0 if neither SELECT statement had
-- an error; otherwise, returns the last error.
RETURN @ErrorSave
GO
Posted
Updated 19-Jul-12 20:47pm
v2

1 solution

Look into the below msdn site.

http://msdn.microsoft.com/en-us/library/59x02y99%28v=vs.90%29.aspx

They have a stored proc with input, output and return. And adding the corresponding directions for the parameters when adding it to sqlcommand.
 
Share this answer
 
v2
Comments
Prashant Bangaluru 20-Jul-12 8:56am    
Thanks for replying.The explanation is in VB language I dont about that.I am a beginner in C# but know about J2EE.If the explanation is in C# I ll be very comfert.Please post if any.Thanks in advance.
Santhosh Kumar Jayaraman 20-Jul-12 8:59am    
http://msdn.microsoft.com/en-us/library/59x02y99%28v=vs.90%29.aspx.. This will have explanation in c#
Prashant Bangaluru 20-Jul-12 9:07am    
Thanks a lot..

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