Matthias and Mike,
This isn't really correct. If you use ExecuteScalar, and the stored
procedure returns a result set, then you will not get the result that you
want.
Rather, what you should do is create a parameterized command (which I
assume you have already) and attach a parameter where the Direction property
is ParameterDirect ion.ReturnValue . This parameter will then get the return
value result.
Hope this helps
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard. caspershouse.co m
"Matthias S." <po*****@emvoid SPAMTRAP.de> wrote in message
news:er******** ******@TK2MSFTN GP15.phx.gbl...
Hi,
ExecuteNonQuery () will return you the rows affected if you do an update,
delete or insert.
you can use the ExecuteScalar() instead which returns the value of the
first colum and field.
hope that helps,
matthias
Mike P wrote:
I have a SQL Server stored procedure that is returning a 0 if the
execution was OK and 1 if not.
e.g. :
commit trans
return 0
on_error:
rollback tran
return 1
I am trying to capture this return value in my C# :
objConnection.O pen();
int intResult = objCommand.Exec uteNonQuery();
objConnection.C lose();
What am I doing wrong?
Any assistance would be really appreciated.
Cheers,
Mike
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!