Solved

SQL return true or False

Posted on 2009-05-03
2
513 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
Comment Utility
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
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
How can I use this extension method? 8 35
Showdialog 8 20
VB.NET HttpWebRequest 12 30
SQL to update characters in table column 6 25
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

771 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

11 Experts available now in Live!

Get 1:1 Help Now