Reputation: 46222
I have the following sniplet of a stored procedure in SQL Server
Create PROCEDURE [dbo].[usp_Genpwd]
@pass varchar(8) OUTPUT
AS
BEGIN
In my c# code, how do I get the output from the stored proc throught the data context?
var pwd = db.usp_Genpwd(..)
Intellisense says to put ref string pass in the paranthesis but when I do the following:
var pwd = db.usp_Genpwd(ref string pass);
I get a invalid arguments error
I am not sure what goes in the paranthesis as I am outputting a value from the stored proc.
Upvotes: 1
Views: 538
Reputation: 887413
A ref
parameter means a reference to a variable or field.
In order to call a function that takes a ref
parameter, you need to pass a variable or field with the ref
keyword:
string v = null;
var pwd = db.usp_Genpwd(ref v);
Upvotes: 1
Reputation: 6260
You should do the following:
ObjectParameter pass = new ObjectParameter("pass", typeof(String));
db.usp_Genpwd(pass);
And pass.Value
will contain the result.
Upvotes: 0