Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 8th, 2004, 04:14 AM
Authorized User
Join Date: Dec 2004
Location: Chennai, TN, India.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to kvanchi
Default stored procedure

i want to return a value from stored procedure
to code behind in vb
how can do that
can any one help me with stored procedure
and how to get that return value in vb

Reply With Quote
  #2 (permalink)  
Old December 9th, 2004, 07:27 AM
Friend of Wrox
Join Date: Jul 2004
Location: Tehran, , Iran.
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post

consider this simple SP,
Create Procedure GetAuthorsCount
Return ( Slect Count(*) From Authors )
below code use that SP and returns the result as a return value,
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Data" %>
Dim conPubs As SqlConnection
Dim cmdAuthorCount As SqlCommand
Dim parmReturnValue As SqlParameter
Dim intAuthorCount As Integer
conPubs = New SqlConnection( "Server=localhost;uid=sa;pwd=secret;database=pubs" )
cmdAuthorCount = New SqlCommand( "GetAuthorCount", conPubs )
cmdAuthorCount.CommandType = CommandType.StoredProcedure
parmReturnValue = cmdAuthorCount.Parameters.Add( "ReturnValue", SqlDbType.Int )
parmReturnValue.Direction = ParameterDirection.ReturnValue
intAuthorCount = cmdAuthorCount.Parameters( "ReturnValue" ).Value
There are <%=intAuthorCount%> records in the Authors table
ofcource,if I were you I would used output parameters instead of return values because,
1-return values just could return integers,
2-return values just return one value,

software engineering student.
Looking for a good job for summer 2005.
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
stored procedure prashant_telkar SQL Server 2000 1 July 9th, 2007 07:57 AM
Stored Procedure jezywrap SQL Server ASP 1 January 3rd, 2007 12:29 AM
stored procedure kdm260 SQL Server 2000 2 June 19th, 2006 04:45 PM
Stored Procedure rajanikrishna SQL Server 2000 0 July 18th, 2005 05:01 AM
Help About Stored Procedure zhuge6 BOOK: ASP.NET Website Programming Problem-Design-Solution 3 May 20th, 2005 09:27 AM

All times are GMT -4. The time now is 09:51 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.