Solved

SQL return true or False

Posted on 2009-05-03
2
526 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

691 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