473,396 Members | 2,111 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,396 software developers and data experts.

stored procedure return value question

hello, i am new to asp.net and sql server, and i have 3 questions for
asking:

1. i am writing a store procedure of login validation for my asp.net
application and wondering what the different between RETURN and SELECT
is.

if exists(select * from users where username = @username and password =
@password)
BEGIN
SELECT 1
RETURN 1
END
ELSE
BEGIN
SELECT 0
RETURN 0
END

2. if i use SqlCommand object's ExecuteScalar() method to get the
stored procedure result, which return value will i get? SELECT value or
RETURN value? is it a usual way for getting a return value by using
ExecuteScalar()?

3. how can i implement a case sensitve validation?

Aug 10 '06 #1
2 2646
I am no guru but i believe the SELECT keyword works the same wherever you put
it. The line SELECT 1 is simply creating a scalar value of 1, ie. a 1 column
one row table where the data consists of the number 1. Return one, returns
the number 1 from the stored pricedure, so if you were calling the stored
procedure from asp.net using for exmaple ado.net the value returned would be
one. As far as i can see the select statments in your two begin end
statments do notjhing at all. The return value is what is reurned to the
ExecuteScalar command.

"philip" wrote:
hello, i am new to asp.net and sql server, and i have 3 questions for
asking:

1. i am writing a store procedure of login validation for my asp.net
application and wondering what the different between RETURN and SELECT
is.

if exists(select * from users where username = @username and password =
@password)
BEGIN
SELECT 1
RETURN 1
END
ELSE
BEGIN
SELECT 0
RETURN 0
END

2. if i use SqlCommand object's ExecuteScalar() method to get the
stored procedure result, which return value will i get? SELECT value or
RETURN value? is it a usual way for getting a return value by using
ExecuteScalar()?

3. how can i implement a case sensitve validation?

Aug 10 '06 #2
sqlserver stored procedures return result sets from a select, and a int
return value (zero if no value specified).

in sql you access the return value with the exec:

exec @returnValue = myproc

in client code it depends on the api. with sqlclient, use a parameter with a
direction of type ReturnValue. the proc return value comes afte all result
sets, so you must read the result sets before its available.

ExecuteScaler returns the value of the first column, of the first row, of
the first result set. you have more than one result set if the proc has more
than one select.

if you are calling a proc that only has a return value, normally you'd use
ExecuteNonquery.

SqlParameter returnValueParam = cmd.Parameters.Add(@return,SqldbType.Int);
returnValue.Direction = ParameterDirection.ReturnValue;
cmd.ExecuteNonQuery();
int returnValue = (int) returnValueParam.Value;
-- bruce
..
"philip" <ma******@gmail.comwrote in message
news:11*********************@p79g2000cwp.googlegro ups.com...
hello, i am new to asp.net and sql server, and i have 3 questions for
asking:

1. i am writing a store procedure of login validation for my asp.net
application and wondering what the different between RETURN and SELECT
is.

if exists(select * from users where username = @username and password =
@password)
BEGIN
SELECT 1
RETURN 1
END
ELSE
BEGIN
SELECT 0
RETURN 0
END

2. if i use SqlCommand object's ExecuteScalar() method to get the
stored procedure result, which return value will i get? SELECT value or
RETURN value? is it a usual way for getting a return value by using
ExecuteScalar()?

3. how can i implement a case sensitve validation?

Aug 10 '06 #3

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

Similar topics

8
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...
15
by: Jarrod Morrison | last post by:
Hi All Im generally a vb programmer and am used to referencing multiple records returned from a query performed on an sql database and im trying to move some functions of my software into sql...
0
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...
2
by: Daniel | last post by:
hi ng, i am newbie to sqlserver and my problem seems simple, but i didn't find information about it: How can i display the RETURN @x value of a stored procedure in the sql analyzer of the...
4
by: laurenq uantrell | last post by:
I need to get the value of an output parameter back into my VBA function calling a stored procedure. I'm using the following construction to append a new record in a SQL Server table: ...
2
by: Dino L. | last post by:
How can I run stored procedure (MSSQL) ?
5
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...
7
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...
9
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....
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.