Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / ADO.NET / March 2008

Tip: Looking for answers? Try searching our database.

Get return code from SQL Server Sproc?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Smokey Grindel - 26 Mar 2008 19:02 GMT
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!
Cowboy (Gregory A. Beamer) - 26 Mar 2008 19:29 GMT
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.

Signature

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!

*************************************************
> Say I have a procedure that returns a return code like the following...
>
[quoted text clipped - 9 lines]
> 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] - 28 Mar 2008 19:33 GMT
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).

Signature

__________________________________________________________________________
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)
____________________________________________________________________________________________

> Say I have a procedure that returns a return code like the following...
>
[quoted text clipped - 9 lines]
> 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!

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.