Solved

SQL return true or False

Posted on 2009-05-03
2
522 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 143

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

How our DevOps Teams Maximize Uptime

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

Question has a verified solution.

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

Suggested Solutions

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…
I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

730 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