Search This Blog

Monday, January 6, 2014

Output Sql Parameter in C#

output parameter is used to get the value from store procedure, if you want to return any value from store procedure then we are using output parameter.
to use output parameter we need to define the direction of the parameter to output.
example the simple example of output parameter is when we are registering any user after registration return the userid and login user into our website.

here is code snippet to change the direction of sqlparameter.

SqlParameter sqlParameter = new SqlParameter(_parameterName, _parameterValue);
sqlParameter.Direction = ParameterDirection.Output;

//then attach parameter to our command object.

String outParameter = Convert.ToString(sqlCommand.Parameters[outParameter].Value);

//here outParameter is the output parameter of store procedure.


No comments:

Post a Comment