Click here to Skip to main content
15,909,741 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi In my storedprocedure i use output value,

create procedure Procedure Name
@Returnvalue int output
as
Begin
Set @Returnvalue =2
end

in my page,
strSPName = "DSp_GetUpdateInsertLookupbyName_Admin";

SqlParameter[] objSqlParameter = new SqlParameter[1];



objSqlParameter[0] = new SqlParameter(@ReturnValue, System.Data.SqlDbType.Int);
objSqlParameter[0].Direction = ParameterDirection.Output;


intReturnValue = (int)objSqlParameter[0].Value;

Result is 0 only but I need to return value is 2

Plz help me

Thanks in advance
Posted
Updated 3-Feb-13 18:21pm
v2
Comments
Nandakishore G N 4-Feb-13 0:39am    
are you passing the output parameter to the sp?i.e,
for ex: cmd.parameters.addWithvalue(objSqlParameter[0]);

Hi, Try this..
SqlParameter objSqlParameter = new SqlParameter("@ID", SqlDbType.Int)
   { 
      Direction = ParameterDirection.Output 
   };
//=============================

int intReturnValue = objSqlParameter .Value as int? ?? default(int); 



For another good example u may go through this link.

http://www.eggheadcafe.com/PrintSearchContent.asp?LINKID=624[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900