C#

Moderators: None (Apply to moderate this forum)
Number of threads: 2720
Number of posts: 5746

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Need help with username and password in sql db Posted by amit2usa on 3 Jun 2009 at 6:15 AM
Hi all,
I am having problem with username string matching ie Upper or lower case.It is accepting username in Small also and in caps alsO ,whenever i am providing the correct username and password.
I am giving u here the code pls reply with correct answer.

private void btnSubmit_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("connection string");
string str;
str=("Select * from Logins where Username='"+txtUsername.Text+"' and Password='"+txtPassword.Text+"' ");
SqlCommand cmd = new SqlCommand(str,con);
con.Open();
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
if (((dt.Rows.Count > 0)&&(txtUsername.Text!=txtUsername.Text.ToLower()))&&(txtPassword.Text!=txtPassword.Text.ToUpper()))
{
MessageBox.Show("WELCOME");
}
else
{

MessageBox.Show("INVALID USERNAME/password");
}
con.Close();
}


Report
Re: Need help with username and password in sql db Posted by Psightoplazm on 3 Jun 2009 at 8:34 AM
So your saying that your data table is receiving results weather the user types in his/her username and password in all caps or all lowercase?

In other words
"SELECT * FROM logins WHERE username='USERNAME'"
is being treated the same as
"SELECT * FROM logins WHERE username='username'"
is this correct?

If that's the case then see if this is also happening in a 3rd party query browser and if it is please post this in the "Applications/Database & SQL" forum because that's a strange issue.
></\/~Psightoplasm`~



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.