Solved

SQL return true or False

Posted on 2009-05-03
2
517 Views
Last Modified: 2012-05-06
i have a Database with column username and password. user will key in username and password in a textbox.
i need SQL code to check, if username in the Database then return true.  if username not avialable in the database then return false.
0
Comment
Question by:aarontham
2 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 250 total points
ID: 24289006
I would use a SqlCommand to return a datareader, and if that reader has no record (if !reader.read()), ...
also, do you want to check the password also, or not?

note: usually, the password is hashed/encrypted in the db, and you have to compare with the hashed/crypted value of the password from user input...
0
 
LVL 10

Assisted Solution

by:oleber
oleber earned 250 total points
ID: 24289026
another way is a

SELECT COUNT(*) FROM my_tab WHERE login=?

if count is 0 then you have no user with that login, bigger then 0 you have an user.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now