How to compare values
-
Hi, I am using DataReader to read data from database and comparing the values with textbox values entered(something like in login page to chk whether the user exists)but even the values are same it displays user not valid. what r the options for comparing values? herez my code if((dr.GetValue(0).ToString().Equals(txtUserName.Text.ToString()))&&(dr.GetValue(1).ToString().Equals(txtPassword.Text.ToString()))) { Response.write("User is valid"); } else { Response.write("User is not valid"); } Thanks, Mini
-
Hi, I am using DataReader to read data from database and comparing the values with textbox values entered(something like in login page to chk whether the user exists)but even the values are same it displays user not valid. what r the options for comparing values? herez my code if((dr.GetValue(0).ToString().Equals(txtUserName.Text.ToString()))&&(dr.GetValue(1).ToString().Equals(txtPassword.Text.ToString()))) { Response.write("User is valid"); } else { Response.write("User is not valid"); } Thanks, Mini
-
Hi, I am using DataReader to read data from database and comparing the values with textbox values entered(something like in login page to chk whether the user exists)but even the values are same it displays user not valid. what r the options for comparing values? herez my code if((dr.GetValue(0).ToString().Equals(txtUserName.Text.ToString()))&&(dr.GetValue(1).ToString().Equals(txtPassword.Text.ToString()))) { Response.write("User is valid"); } else { Response.write("User is not valid"); } Thanks, Mini
Well one another way is that u must compare by applying == among two string like... dr.GetValue(0)==txtUserName.Text may be this will helpfull.. KHATRI
-
Hi, I am using DataReader to read data from database and comparing the values with textbox values entered(something like in login page to chk whether the user exists)but even the values are same it displays user not valid. what r the options for comparing values? herez my code if((dr.GetValue(0).ToString().Equals(txtUserName.Text.ToString()))&&(dr.GetValue(1).ToString().Equals(txtPassword.Text.ToString()))) { Response.write("User is valid"); } else { Response.write("User is not valid"); } Thanks, Mini
Well you can also compare the two values by applying == to them Like dr.GetValue(0)==txtUserName.Text similarly u can do more.. May be this is helpfull to u Khatri
-
Well you can also compare the two values by applying == to them Like dr.GetValue(0)==txtUserName.Text similarly u can do more.. May be this is helpfull to u Khatri
I would suggest that you relegate this task to the database by changing your query and adding filter for username and password (if applicable) As for comparison, you can make both values upper case/lower case and then compare (if they are strings) or use object comparison (for objects).
Shreekar http://shreekarishere.blogspot.com
-
Hi, I am using DataReader to read data from database and comparing the values with textbox values entered(something like in login page to chk whether the user exists)but even the values are same it displays user not valid. what r the options for comparing values? herez my code if((dr.GetValue(0).ToString().Equals(txtUserName.Text.ToString()))&&(dr.GetValue(1).ToString().Equals(txtPassword.Text.ToString()))) { Response.write("User is valid"); } else { Response.write("User is not valid"); } Thanks, Mini
Try the following code if((dr.GetValue(0).ToString()==txtUserName.Text.ToString())&&(dr.GetValue(1).ToString()==txtPassword.Text.ToString())) { Response.write("User is valid"); } else { Response.write("User is not valid"); } :) Thanks and Regards, Suresh Dayma
Everything Is Possible!
-
Try the following code if((dr.GetValue(0).ToString()==txtUserName.Text.ToString())&&(dr.GetValue(1).ToString()==txtPassword.Text.ToString())) { Response.write("User is valid"); } else { Response.write("User is not valid"); } :) Thanks and Regards, Suresh Dayma
Everything Is Possible!
Thanks to all.. All ur replies r working fine... Thanks, Mini