By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,815 Members | 1,152 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,815 IT Pros & Developers. It's quick & easy.

getting the return value from a stored procedure

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
"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 discussion thread is closed

Replies have been disabled for this discussion.