Click here to Skip to main content
11,714,345 members (88,277 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
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 3-Feb-13 18:10pm
24983691
Edited 3-Feb-13 18:21pm
v2
Comments
Nandakishorerao at 4-Feb-13 0:39am
   
are you passing the output parameter to the sp?i.e,
for ex: cmd.parameters.addWithvalue(objSqlParameter[0]);
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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[^]
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 430
1 Maciej Los 229
2 Richard MacCutchan 210
3 CHill60 175
4 OriginalGriff 175
0 Sergey Alexandrovich Kryukov 365
1 CHill60 335
2 OriginalGriff 245
3 Andy Lanng 173
4 Richard MacCutchan 150


Advertise | Privacy | Mobile
Web02 | 2.8.150819.1 | Last Updated 4 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100