Groups | Blog | Home
all groups > dotnet ado.net > march 2008 >

dotnet ado.net : Get return code from SQL Server Sproc?


Cowboy (Gregory A. Beamer)
3/26/2008 1:29:39 PM
Create a parameter for @RETURN_VALUE. It will automatically be connected to
the return statement. With SQL Server 7 or earlier, it is merely
RETURN_VALUE, but I doubt many of us are still in that world.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:
http://gregorybeamer.spaces.live.com/

*************************************************
| Think outside the box!
|
*************************************************
[quoted text, click to view]

Smokey Grindel
3/26/2008 2:02:57 PM
Say I have a procedure that returns a return code like the following...

CREATE PROCEDURE TestProc
AS
BEGIN
SET NOCOUNT ON;
SELECT *
FROM MyTable;
RETURN 10
END


And I execute that in a sql command object, how does my client application
get the return code back? Which in this case is 10.. thanks!

William Vaughn [MVP]
3/28/2008 11:33:39 AM
With ADO.NET you need to set the Parameter Direction property to indicate
that this is a ReturnValue. The parameter name is irrelevant--you could call
it @Fred as long as the Direction is set to ReturnValue (based on the
intellisense choices).

--
__________________________________________________________________________
William R. Vaughn
President and Founder Beta V Corporation
Author, Mentor, Dad, Grandpa
Microsoft MVP
(425) 556-9205 (Pacific time)
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
____________________________________________________________________________________________
[quoted text, click to view]
AddThis Social Bookmark Button