How to pass output value from Stored Procedure to asp.net 1.1 using C#

Posted by Mahendrabasutkar under ASP.NET on 8/4/2011 | Points: 10 | Views : 2090 | Status : [Member] | Replies : 3
How to pass output value from Stored Procedure (written in sqlserver 2000) to asp.net 1.1 using C#


Regards,
mahendrabasutkar




Responses

Posted by: Hmanjarawala on: 8/4/2011 [Member] Bronze | Points: 25

Up
0
Down
Hi Mahendra Here is the code:

SqlConnection con = new SqlConnection("<connectionString>")
con.Open();

SqlCommand com = new SqlCommand("<storeProcedureName>", con);
com.CommandType = CommandType.StoreProcedure;

com.Parameters.Add("<param1>", SqlDBType.Varchar);
com.Parameters[0].Direction = ParameterDirection.Output;

com.ExecuteNonProcedure()
Object val = com.Parameters[0].Value;

Hope this will helps you

Himanshu Manjarawala
Sr. Software Engineer@AutomationAnywhere
http://fieredotnet.wordpress.com/

Mahendrabasutkar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Mahendrabasutkar on: 8/4/2011 [Member] Starter | Points: 25

Up
0
Down
Hi Himanshu,


I'm using sql server 2000, probably 'com.ExecuteNonProcedure() will not support, i think, since i'm getting error there.
Even i have replace it to 'com.ExecuteReader()', but the value of 'val' is showing as 0.
please help me on this.

Thanks & Regards,
Mahendra

Mahendrabasutkar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hmanjarawala on: 8/4/2011 [Member] Bronze | Points: 25

Up
0
Down
Sorry, Mahendra its my mistake just replace it with com.ExecuteNonQuery()

Himanshu Manjarawala
Sr. Software Engineer@AutomationAnywhere
http://fieredotnet.wordpress.com/

Mahendrabasutkar, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response