473,402 Members | 2,046 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Catching return values of an SP

I have calling a stored procedure that returns two values, and I want
to catch these values and to store them into a variable.
Here is a piece of my SP inside SQL Server that shows the returned
values:

SELECT @Id = SCOPE_IDENTITY()
SELECT @Id AS user_id
SELECT 1 AS Value
END
GO

In my aspx page I am trying to call the first value like this:
[code:1:6ec0af7d1c]
Dim nID
CmdInsert.Parameters.Add(New
SqlParameter("@RETURN_VALUE", SqlDbType.bigint, 8,
"user_id"))
CmdInsert.Parameters("@RETURN_VALUE").Direction =
ParameterDirection.ReturnValue
CmdInsert.Parameters("@RETURN_VALUE").Value = nID
[/code:1:6ec0af7d1c]

And to check if the right value is returned I use:
[code:1:6ec0af7d1c]
strConnection.open()
cmdInsert.ExecuteNonQuery
'Set the value of a textbox
ident.text = nID
strConnection.close()
[/code:1:6ec0af7d1c]
But no value appears in the textbox, How can I achieve it? What is
wrong?
[/code]
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 18 '05 #1
2 1308
Have you declared your parameter in your stored procedure as output?

create proc myprocname(
@myReturnValue int output
) as
"cesark" <ce************@hotmail-dot-com.no-spam.invalid> wrote in message
news:40********@Usenet.com...
I have calling a stored procedure that returns two values, and I want
to catch these values and to store them into a variable.
Here is a piece of my SP inside SQL Server that shows the returned
values:

SELECT @Id = SCOPE_IDENTITY()
SELECT @Id AS user_id
SELECT 1 AS Value
END
GO

In my aspx page I am trying to call the first value like this:
[code:1:6ec0af7d1c]
Dim nID
CmdInsert.Parameters.Add(New
SqlParameter("@RETURN_VALUE", SqlDbType.bigint, 8,
"user_id"))
CmdInsert.Parameters("@RETURN_VALUE").Direction =
ParameterDirection.ReturnValue
CmdInsert.Parameters("@RETURN_VALUE").Value = nID
[/code:1:6ec0af7d1c]

And to check if the right value is returned I use:
[code:1:6ec0af7d1c]
strConnection.open()
cmdInsert.ExecuteNonQuery
'Set the value of a textbox
ident.text = nID
strConnection.close()
[/code:1:6ec0af7d1c]
But no value appears in the textbox, How can I achieve it? What is
wrong?
[/code]
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com

Nov 18 '05 #2
Jon
Hi,
you'd probably want something like this
In your sp
Create Procedure Whatever
@id int OUTPUT
as
.....
select @id = scope_identity()

and then to get the value
Dim id As SqlParameter = New SqlParameter("@id", SqlDbType.Int, 4)
id.Direction = ParameterDirection.Output
cmdInsert.Parameters.Add(id)
cmdInsert.executenonquery()
response.write("new id is " & cmdInsert.Parameters("@ID").Value)

Jon

"cesark" <ce************@hotmail-dot-com.no-spam.invalid> wrote in message
news:40********@Usenet.com...
I have calling a stored procedure that returns two values, and I want
to catch these values and to store them into a variable.
Here is a piece of my SP inside SQL Server that shows the returned
values:

SELECT @Id = SCOPE_IDENTITY()
SELECT @Id AS user_id
SELECT 1 AS Value
END
GO

In my aspx page I am trying to call the first value like this:
[code:1:6ec0af7d1c]
Dim nID
CmdInsert.Parameters.Add(New
SqlParameter("@RETURN_VALUE", SqlDbType.bigint, 8,
"user_id"))
CmdInsert.Parameters("@RETURN_VALUE").Direction =
ParameterDirection.ReturnValue
CmdInsert.Parameters("@RETURN_VALUE").Value = nID
[/code:1:6ec0af7d1c]

And to check if the right value is returned I use:
[code:1:6ec0af7d1c]
strConnection.open()
cmdInsert.ExecuteNonQuery
'Set the value of a textbox
ident.text = nID
strConnection.close()
[/code:1:6ec0af7d1c]
But no value appears in the textbox, How can I achieve it? What is
wrong?
[/code]
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com

Nov 18 '05 #3

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

Similar topics

6
by: Karl A. Krueger | last post by:
I'm in the middle of refactoring a small mod_python Web application, which uses the Publisher handler. This application is currently a single main Python file (which loads several other files as...
8
by: Adam H. Peterson | last post by:
Hello, I sometimes find myself writing code something like this: try { Derived &d=dynamic_cast<Derived&>(b); d.do_something_complicated(); // etc.... } catch (std::bad_cast) { throw...
2
by: fred | last post by:
Hello, I read a file from several classes and want to catch an EOF when it appears. Having caught the EOF I want to allow the final part of the program to continue rather than just exiting. ...
0
by: darrel | last post by:
I have a function that I pass some variables to, that then goes into an XML file and returns some other values: dim expr as System.Xml.XPath.XPathExpression = xpn.Compile("//" & variableToReturn...
5
by: Andrea | last post by:
....without changing the data type. I have been working on this for over 5 hours, please help me so I don't have to shoot myself. It's due by midnight... Here's my code: (Variables are declared...
2
by: Eric Lilja | last post by:
Hello, consider this complete program: #include <iostream> #include <string> using std::cout; using std::endl; using std::string; class Hanna {
1
by: satish mullapudi | last post by:
Hi, I am using DB2 v8.2 & jdk 1.4. 1. I have a java program which returns an array which contains 1 to 5 numbers. The code: public class ArrayTest { public static final int ARRAY_SIZE = 5;...
12
by: Karlo Lozovina | last post by:
I'm not sure if Python can do this, and I can't find it on the web. So, here it goes: try: some_function() except SomeException: some_function2() some_function3() ...
3
by: john | last post by:
I wrapped some fortran code using F2PY and need to be able to catch fortran runtime errors to run the following: # "grid" is a wrapped fortran module # no runtime errors incurred when run with...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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...

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.