|
-
Jun 5th, 2006, 09:22 PM
#1
Thread Starter
Lively Member
Does the SELECT statement return a value?
Hi,
I am setting up a user login account database. It consists of a table containg ID, username and password attributes.
First,the database will be searched to see if such a user exists.
What happens if the SELECT statement doesnt find a match? Does it return a value to indicate that there is no record found?
-
Jun 6th, 2006, 05:16 AM
#2
Hyperactive Member
Re: Does the SELECT statement return a value?
Hello Lilo,
No the select statement will not inform the user of no records found but within the select statement you could use a COUNT(ID) AS mycount following the Select tablename.ID then test the value of mycount > 0.
Steve
-
Jun 6th, 2006, 06:16 AM
#3
Re: Does the SELECT statement return a value?
A SELECT will open and create a recordset. Whether there is anything in the recordset will determine if the username is found. If you compare what is returned to what has been typed into the login textbox, you will know whether there is match.
-
Jun 6th, 2006, 06:31 AM
#4
-
Jun 16th, 2006, 03:21 AM
#5
Thread Starter
Lively Member
Re: Does the SELECT statement return a value?
yup thanks for the replies guys
-
Jun 16th, 2006, 04:30 AM
#6
Addicted Member
Re: Does the SELECT statement return a value?
If you don't want to actually do anything with the user record other than check it exists I wouldn't even use a recordset. Your adding unecessary weight to your application.
A typical command would be :
Code:
SELECT Count(UserID)
FROM tbl_Users
WHERE UserName LIKE @UserName
AND Password = @Password
Execute this using a connection and a command to populate the parameters and get the return value and you'll have a more robust application.
You should always use parameterised SQL where ever possible.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|