Howdy, Stranger!

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

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

String matching from database

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);
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();
}


Sign In or Register to comment.