aspdotnet-suresh offers articles and tutorials,csharp dot net, articles and tutorials,VB.NET Articles,Gridview articles,code examples of 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

Get output parameter from stored procedure in

Jul 9, 2012

In this article I will explain how to get output parameters returns by stored procedure in


In previous posts I explained many articles relating,
gridview, JQuery, SQL Server etc. Now I will explain how to get output parameters return by stored procedure in First we will see how to write a stored procedure to return output parameters for that check this post write stored procedure to return output parameters in SQL Server. Once stored procedure designed in database write the following code in code behind to get output parameters returns by stored procedure in

Generally if we want to get output parameters return by stored procedure in we will write like this

C# Code

string message = String.Empty;
SqlCommand cmd = new SqlCommand("sp_userinformation", con);
cmd.Parameters.Add("@Output", SqlDbType.Char, 500);
cmd.Parameters["@Output "].Direction = ParameterDirection.Output;
message = (string) cmd.Parameters["@Output "].Value;
Here sp_userinformation is a stored procedure and @Output is parameter which is used to get the output parameter return by stored procedure.


Dim message As String = [String].Empty
Dim cmd As New SqlCommand("sp_userinformation", con)
cmd.Parameters.Add("@Output", SqlDbType.[Char], 500)
cmd.Parameters("@Output ").Direction = ParameterDirection.Output
message = DirectCast(cmd.Parameters("@Output ").Value, String)
If you want to know how to write this code in application check this post

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest,, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email


Chandru said...

Ther Article was nice. But i have found one error while exeucting the Sp in my front end is mentioned here weather i need to execute the command right but in u r post u have not done that so i confused

Anonymous said...

message = (string) cmd.Parameters["@Output "].Value;
how to bring the message in view

Anonymous said...

please answer my

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.