I don't know the answer to that (one of the folks in the SQL Server
programming forum would, see microsoft.public.sqlserver.programming). It
might also help to see a small segment of code on how you are setting the
parameters in .Net.
the problem is in ADO.NET, because if i run the query from the profiler
in
query analyzer, the results are OK.
actually the ADO.NET sends to the SQL the parameters without getting it's
return value.
for example, the query without setting the output parameter to null
before
the call looks like that:
on the RPC:Starting event
declare @P1 varchar(50)
set @P1=NULL
exec MySp @a = N'val', @ret = @P1 output
select @P1
the query looks defferently if the only little change that i do before
the
call is setting the output parameter to null (whether i change it's type to
input-output or just leaves it as output parameter):
exec MySp @a = N'val', @ret = NULL
well i guess it can explain why the return value don't come back, but why in
the first place the query should be changed because of setting an initial
value to an output parameter ???
TIA, z.
Use the Profiler when you run your SP and check the parameters. That should
show you where the problem lies.
if for the @user_id i set to dbnull.value when i call the SP ( never mind
the logic that in this case i don't check this value, in other SP i do check
the value of an input-output parameter.)
i can't get the return value correctly.
If you run that in the QA will it execute with the comma after [user_id]?
In any event, you had initially posted:
"when i send an input value of null, the return value does not return
correctly and i get null in return even if the SP set the value to something
else." But you also say, "when the output parameter value is not null, it
returns correctly. when it is null, it returns null."
I'm not clear what input value of null that you are talking about is
being
set for what parameters?
z f said:
the SP looks like that:
(but again i don't think it has a problem, since when the output parameter
value is not null, it returns correctly. when it is null it returns null.)
ALTER procedure Login
(
@email varchar (100),
@password varchar (20),
@user_id int output,
@roles nvarchar (100) output
)
as
select
@roles = roles ,
@user_id = [user_id] ,
from users
where @email = email
and @password = password
and enabled = 1
Depends on how the "SP set the value to something else", so it sounds
like
the problem is in the SP. You might want to post that here and/or on the
microsoft.public.sqlserver forums.
hi,
i use ado.net to call a stored procedure in SQL Server 2000.
the SP have a parameter that is input and output
when i send an input value of null, the return value does not return
correctly and i get null in return even if the SP set the value to
something
else.
if the initial value is not null, the return value of the output
parameter
is received correctly.
what's the problem???
TIA, z.