My stored procedure need to return 5 different values and want to use those value in .NET. Stored procedure
CREATE PROCEDURE GET_NAME
(
@COUNT INT
)
AS
BEGIN
SET NOCOUNT ON;
DECLARE NAME1 AS VARCHAR(100)
DECLARE NAME2 AS VARCHAR(100)
DECLARE NAME3 AS VARCHAR(100)
SET @NAME1 = (SELECT DRIVER FROM TABLE1 WHERE @COUNT = 10)
SET @NAME2 = (SELECT DRIVER FROM TABLE2 WHERE @COUNT = 10)
SET @NAME3 = (SELECT DRIVER FROM TABLE3 WHERE @COUNT = 10)
SELECT @NAME1
SELECT @NAME2
SELECT @NAME3
END
Now at .NET, I know ExecuteDataset function can use to retrieve multiple data, but I don't know how to get into three different variables as stored procedure returning 3 different output. Desired output I need is .NET variables store values from sp.
If someone knows, please help me. Thank you
CodePudding user response:
CREATE PROCEDURE GET_NAME
@COUNT INT,
@NAME1 VARCHAR(100) OUTPUT,
@NAME2 VARCHAR(100) OUTPUT,
@NAME3 VARCHAR(100) OUTPUT
AS
BEGIN
SET NOCOUNT ON;
SET @NAME1 = (SELECT DRIVER FROM TABLE1 WHERE @COUNT = 10)
SET @NAME2 = (SELECT DRIVER FROM TABLE2 WHERE @COUNT = 10)
SET @NAME3 = (SELECT DRIVER FROM TABLE3 WHERE @COUNT = 10)
END