Need help with username and password in sql db - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Need help with username and password in sql db

amit2usaamit2usa Posts: 3Member
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);
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
if (((dt.Rows.Count > 0)&&(txtUsername.Text!=txtUsername.Text.ToLower()))&&(txtPassword.Text!=txtPassword.Text.ToUpper()))

MessageBox.Show("INVALID USERNAME/password");


  • PsightoplazmPsightoplazm Posts: 332Member ✭✭
    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.
Sign In or Register to comment.