473,320 Members | 1,867 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,320 software developers and data experts.

getting the return value from a stored procedure

Hello,
I have a stored procedure that returns a value but does not select any rows as shown below
How can I access the value of this return value from the database using datasets or dataadapters.

Thanx in advance

Geri

:procedure in question
CREATE PROCEDURE SPSelectUserID as

DECLARE @USERNAME varchar(50)
DECLARE @USERID int

EXEC SPSelectUserLogin @USERNAME = @USERNAME OUTPUT
SELECT @USERID = UserID FROM JobControl WHERE UserName = @USERNAME

RETURN @USERID

Nov 20 '05 #1
3 8168
Geraldine,
How can I access the value of this return value from the database using datasets or dataadapters.
Short answer: You don't.

Long answer: You need to use the Command object of the respective client you
are using.

Something like (untested):
Dim command As New SqlClient.SqlCommand("SPSelectUserID",
theConnection)
Dim parm As SqlClient.SqlParameter
parm = command.Parameters.Add("@ReturnValue", SqlDbType.Int)
parm.Direction = ParameterDirection.ReturnValue
command.Parameters.Add("@USERNAME", SqlDbType.VarChar, 50)

command.ExecuteNonQuery()

Dim userid As Integer = DirectCast(parm.Value, Integer)

Hope this helps
Jay

"Geraldine Hobley" <an*******@discussions.microsoft.com> wrote in message
news:40**********************************@microsof t.com... Hello,
I have a stored procedure that returns a value but does not select any rows as shown below How can I access the value of this return value from the database using datasets or dataadapters.
Thanx in advance

Geri

:procedure in question
CREATE PROCEDURE SPSelectUserID as

DECLARE @USERNAME varchar(50)
DECLARE @USERID int

EXEC SPSelectUserLogin @USERNAME = @USERNAME OUTPUT
SELECT @USERID = UserID FROM JobControl WHERE UserName = @USERNAME

RETURN @USERID

Nov 20 '05 #2
In article <40**********************************@microsoft.co m>,
an*******@discussions.microsoft.com says...
Hello,
I have a stored procedure that returns a value but does not select any rows as shown below
How can I access the value of this return value from the database using datasets or dataadapters.


"HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and
Visual Basic .NET"
http://support.microsoft.com/default...b;en-us;308049

--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele
Nov 20 '05 #3
"Geraldine Hobley" <an*******@discussions.microsoft.com> schrieb
Hello,
I have a stored procedure that returns a value but does not
select any rows as shown below
How can I access the value of this return value from the database
using datasets or dataadapters.

[...]


Doesn't seem to be a VB.NET language problem. Please turn to
microsoft.public.dotnet.framework.adonet
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #4

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

Similar topics

3
by: Vipul Pathak | last post by:
Hello Friends ! I have the Following Code, that Executes a Stored Procedure and Attempt to read a Returned Integer Value from the StoredProc. But It gives Error ... ADODB.Command (0x800A0BB9)...
1
by: Greg Smith | last post by:
I am trying to write a SQL query that will return a record count to my C# application. I wrote the following query: ALTER PROCEDURE up_justification_duplicate AS SELECT COUNT(*) FROM...
4
by: Mike Dinnis | last post by:
Hi, I've been working through a number of turorials to try to learn more about retrieving data from a SQL database. I think i've mastered techniques where i create a sql string in the page and...
2
by: Martin Raychev | last post by:
Hi all, I have the following problem: I have a private method that returns a SqlDataReader. For this to work I have not to close the DB connection in the above method. I do this only to
6
by: Max | last post by:
Anyone know why I'm always getting 0 returned? My stored procedure returns -1. Dim iErrorCode As Int32 iErrorCode = Convert.ToInt32(SqlHelper.ExecuteScalar(AppVars.strConn, _ "gpUpdateMember",...
6
by: Uday | last post by:
Hi everyone, I have a ASP page that triggers a db-side stored procedure. At the end of the procedure, it spits out a log file, that this ASP page reads and displays for the users. But the...
4
by: Mick Walker | last post by:
Hi Everyone, I am stumped here. I have the following stored proceedure:P CREATE PROCEDURE . @SupplierSKU varchar(50), @RetVal int AS Select @Retval = count(*) from dbo.ImportLines Where =...
1
by: raghuvendra | last post by:
Hi I have a jsp page with 4 columns: namely Category name , Category order, Input field and a submit button. All these are aligned in a row. And Each Category Name has its corresponding Category...
12
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.