472,992 Members | 3,200 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,992 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 2624
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....
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.