PROBLEM:
Exact string comparison in C# ,Case sensitive login in C#. Suppose you are storing login in database table as "Admin" and on the webpage or winform you are trying to compare it as "admin" then it is pass.But if you want to compare it as exact "Admin" the follow below steps:
Store "admin" in database table. So "admin" and "Admin" is not same
SOLUTION:
String tmpLogin="Admin";
// Select user_login from user_info where user_login='Admin'
String ret_login=Util.getLogin(tmpLogin);
// It will return "admin" so "admin" and "Admin" is not same. so it should false.
if (String.Equals(tmpLogin, ret_login, StringComparison.Ordinal)==false) {
MessageBox.Show("Incorrect User Name.");
label7.Text = "Incorrect UserName.";
return;
} else {
MessageBox.Show("Correct User Name.");
}
Exact string comparison in C# ,Case sensitive login in C#. Suppose you are storing login in database table as "Admin" and on the webpage or winform you are trying to compare it as "admin" then it is pass.But if you want to compare it as exact "Admin" the follow below steps:
Store "admin" in database table. So "admin" and "Admin" is not same
SOLUTION:
String tmpLogin="Admin";
// Select user_login from user_info where user_login='Admin'
String ret_login=Util.getLogin(tmpLogin);
// It will return "admin" so "admin" and "Admin" is not same. so it should false.
if (String.Equals(tmpLogin, ret_login, StringComparison.Ordinal)==false) {
MessageBox.Show("Incorrect User Name.");
label7.Text = "Incorrect UserName.";
return;
} else {
MessageBox.Show("Correct User Name.");
}
0 comments:
Post a Comment