473,785 Members | 3,142 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

stored procedure return value to ASP

JT
how can i see a stored procedures return value in ASP??
Jul 19 '05 #1
7 5730
"JT" <jt@nospam.co m> wrote in message
news:e0******** ******@TK2MSFTN GP10.phx.gbl...
how can i see a stored procedures return value in ASP??


Assign the results to a Recordset. Assuming you have a connection variable
dbConn, and your stored procedure is named sq_myStoredProc :

Set oRS = dbConn.Execute( "exec sq_myStoredProc " )

Regards,
Peter Foti
Jul 19 '05 #2
JT wrote:
how can i see a stored procedures return value in ASP??


Use a Command object. I've created a stored procedure code generator that is
available here:
http://www.thrasherwebdesign.com/ind...asp&c=&a=clear

After executing the Command, use

cmd.Parameters( 0).value

to retrieve the Return value. Note, if your procedure also returns a
recordset, you have to retrieve the entire recordset (or close it) before
the return or output parameter values are accessible. Make sure you use SET
NOCOUNT ON in your stored procedure to avoid extra resultsets containing the
"x records affected" messages.

Although others will suggest using a recordset, I consider it to be highly
wasteful of sql server resources, network resources, and web server
resources to use a bulky recordset to retrieve a single value from your
database.

Bob barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #3
Also see
http://www.aspfaq.com/params.htm

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
"JT" <jt@nospam.co m> wrote in message
news:e0******** ******@TK2MSFTN GP10.phx.gbl...
how can i see a stored procedures return value in ASP??

Jul 19 '05 #4
"JT" wrote:

how can i see a stored procedures return value in ASP??


I have found that one easy way is to forego RETURN in favor of SELECT in the
SP, as my colleagues have a greater comfort level with ADODB.Recordset
objects than with ADODB.Command ones.

When doing so, it is useful to wrap all but the output SELECT in a NOCOUNT
block:

CREATE PROCEDURE MySP ( ...parameters.. .) AS
SET NOCOUNT ON
{ perform insert/update as required }
SET NOCOUNT OFF
SELECT @@IDENTITY AS ReturnValue

You can then examine [rs.Fields("Retu rnValue").Value] in your script.

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 19 '05 #5
> When doing so, it is useful to wrap all but the output SELECT in a NOCOUNT
block:

CREATE PROCEDURE MySP ( ...parameters.. .) AS
SET NOCOUNT ON


Or, just always put SET NOCOUNT ON at the beginning of all procedures.
There is no reason to SET NOCOUNT OFF.

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
Jul 19 '05 #6
"Aaron Bertrand [MVP]" wrote:

Or, just always put SET NOCOUNT ON at the beginning of
all procedures. There is no reason to SET NOCOUNT OFF.


There is one reason, but maybe not for everyone. If you use Query Analyzer
to test/debug your procedures, the count information is occasionally useful.
--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 19 '05 #7
I would rather manually add that in using @@ROWCOUNT during debugging, then
I can print custom messages along with it. For a long procedure, this isn't
particularly useful to me:

1 rows(s) affected.

14 rows(s) affected.

5 rows(s) affected.

12 rows(s) affected.

0 rows(s) affected.

10 rows(s) affected.

....because then I have to walk through my stored procedure and figure out
which count went with which statement. Note that one statement can produce
more than one count (e.g. insert into a table with a trigger).

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
"Dave Anderson" <GT**********@s pammotel.com> wrote in message
news:%2******** *******@TK2MSFT NGP10.phx.gbl.. .
"Aaron Bertrand [MVP]" wrote:

Or, just always put SET NOCOUNT ON at the beginning of
all procedures. There is no reason to SET NOCOUNT OFF.
There is one reason, but maybe not for everyone. If you use Query Analyzer
to test/debug your procedures, the count information is occasionally

useful.

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use of this email address implies consent to these terms. Please do not contact me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.

Jul 19 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
11354
by: C Kirby | last post by:
In SQL Server 2000, I've got a rather lengthy stored procedure, which creates a lot of temporary tables as it processes down through a few sets of data. When testing it through Query Analyzer, it runs fine (a bit slow though). But when I try to run it through the ade, it doesn't do anything. It runs through the procedure in milliseconds but doesn't seem to ever actually start it. If I change the calling code in the ade VBA to refer to...
0
6704
by: Nashat Wanly | last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET View products that this article applies to. This article was previously published under Q310070 For a Microsoft Visual Basic .NET version of this article, see 308049. For a Microsoft Visual C++ .NET version of this article, see 310071. For a Microsoft Visual J# .NET version of this article, see 320627. This article refers to the following Microsoft .NET...
2
5459
by: Dino L. | last post by:
How can I run stored procedure (MSSQL) ?
5
6851
by: Sandy | last post by:
Hello - I need a good example of how to take a return value from a stored procedure and use it in vb code. I have an app that searches a database by city and state. If a user makes a typo, the info sent to the stored procedure makes the stored procedure fail. I want to be able to display a label indicating they should try again, if this is the case. I can't use row count, because the stored procedure doesn't get that far. What...
7
9716
by: Siv | last post by:
Hi, I have a stored procedure that I want to execute and then wait in a loop showing a timer whilst it completes and then carry on once I get notification that it has completed. The main reason for this being to stop the user thinking the application has frozen when in fact it is just waiting for a long SP to complete. Another reason for doing it like this is that I also have had a problem in the past where the SP takes longer than the...
4
3996
by: nishi57 | last post by:
I hope I can get some help regarding this issue, which has been going on for a while. I have a desktop user who is having problem running "Stored Procedures". The DB2 Connect application works fine but when he runs the stored procedure, he gets the following error message. "SYSPROC".CSGCSB54 - Run started. Data returned in result sets is limited to the first 100 rows. Data returned in result set columns is limited to the first 20...
4
4363
by: scparker | last post by:
Hello, We have a stored procedure that does a basic insert of values. I am then able to retrieve the ID number created for this new record. We are currently using ASP.NET 2.0 and use N-Tier Architecture. The Stored Procedures are used through TableAdaptors, which in turn are used by Class Files. I wish to be able to return this new ID value using the Stored
9
4147
by: fniles | last post by:
I am using VB.NET 2003 and SQL2000 database. I have a stored procedure called "INSERT_INTO_MYTABLE" that accepts 1 parameter (varchar(10)) and returns the identity column value from that table. When calling the stored procedure from VB.NET, in the CommandText, can I just say "INSERT_INTO_MYTABLE '12345'" instead of calling it with "INSERT_INTO_MYTABLE" then do the following : OleDbCommand2.Parameters.Add("@Account", SqlDbType.VarChar, 10)...
9
2468
by: Frawls | last post by:
Hi I Am am having problems with a stored Procedure that i wrote. Basically whats happening is that the Stored procedure Runs fine when i EXECUTE it in SQL Query analyzer. But when i debug through the application in Visual Studio .NET 2003 the application an exception when it executes the query.
12
5142
by: Dooza | last post by:
I have a stored procedure that takes a number of inputs, does a bulk insert, and then outputs a recordset. When I run the stored procedure in Server Management Studio I also get a return value from the stored procedure which is an INT. I want to access this return value on my ASP/VBScript page, but do not know how to access it. Here is my code so far:
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10151
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10092
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8973
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3647
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.