.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Melody Anderson
Eminent IT

Home >> Forum >> Sql Server >> Post New QuestionBookmark and Share Subscribe to Forum

Have doubt in store procedure in sql server

Posted By: Suresh     Posted Date: March 05, 2009    Points:2   Category :Sql Server
hello friends
i have created small store procedure, which i have intialised to output field.this is my sample one

alter PROCEDURE insertmytable
@Username VarChar(50),
@Password varchar(50),
@Result VarChar(50) output,
@person varchar(100) output

here i can get exact results. my doubt is we can create multiple output field , and whts the use in this. can u plz explain clearly.
wheather we should need to create only one output field.

Author: Amit Mehra             
Posted Date: March 05, 2009     Points: 5   

Hi Suresh,
try like this to get the output Variable value from Stored procedure

Pass the Value to stored procedure like this

SqlParameter MySqlParameter = new SqlParameter("@Result", "");
MySqlParameter .Direction = ParameterDirection.Output;
cmd.Parameters.Add(MySqlParameter ); //cmd your SQLcommand class object

Now to get the output variable result after executing the Stored procedure you will get the value returned by stored procedure like this

string result= cmd.Parameters["@Result"].Value.ToString();

Similarly you can use for rest of the output variable also.

Please "Mark As Answer " if this post help you.
Author: Suresh             
Posted Date: March 05, 2009     Points: 5   

hi amit

I got correct result, but my doubt is, how many output field we can create in store procedure. whts is the use in this. b'coz i had created two output field in my store procedure. whether its good programing one. can u plz clearly explain it.

Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend