Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't Figure Out If anything is returned

Status
Not open for further replies.

jlindahl

Programmer
Sep 23, 2003
46
0
0
US
I have a stored procedure that I can't tell if it is working.

<code>
alter procedure dbo.confirmcomplete
(
@requestID varchar(50)
)
as
set nocount on;

if not exists (select mId from table where mID = @requestID)
return(0)

else
if not exists (select mID from table where mId = @requestID and mCriteria2 = @criteria2)
return(2)

</code>

this stored procedure seems to no be sending the return values 0 or 2.

Please help. I have code that depends on the return values of these sp's.

Thanks.
 
After thinking, I shouldn't have to create an output parameter right? Can't you use the return command to return an interger value and use either executescalar or executenonquery?
 
but to use those properties, i must return a recordset, right?
That is not what i want to do. I only want a single value returned that i check against a case statement.
 
and your stored procedure doesn't return anything? or it is but you cannot read what that value is?

--------------------------
"two wrongs don't make a right, but three lefts do" - the unknown sage
 
It seems that i have figured it out late last night. My stored procedure does return an integer value. What i ended up doing was setting up a returnvalue parameter in my asp page. This allowed me to get the 'Return()' value from the stored procedure.
 
you can also use it as an sqlcommand and use ExecuteScalar to get the only value

--------------------------
"two wrongs don't make a right, but three lefts do" - the unknown sage
 
That is what i thought too, but i could not read the returned value.
 
it is an object.

Object o = myCommand.ExecuteScalar();
if (o != null)
int value = (int)o;

--------------------------
"two wrongs don't make a right, but three lefts do" - the unknown sage
 
So all i have to do is set my variable to an object datatype? I will give that a try this evening.
 
yes

--------------------------
"two wrongs don't make a right, but three lefts do" - the unknown sage
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top