0

I am saving all kinds of usernames and passwords in one table, however to differentiate the category there is third column that represents either he is clerk or administrator or teacher etc....the code is comparing username and password well but the third comparison is always returning false

here is my code

if (reader.GetString(0).Equals(password.Text))
            {
                if (reader.GetString(1).ToString().Equals("Clerk"))
                    Response.Redirect("clerkmain.aspx");
                else
                    status.InnerHtml="You are not Allowed to Login";}

while the third column in this row is exactly named "Clerk" with datatype of varchar

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
sayyed Saulat
  • 103
  • 1
  • 7

1 Answers1

0

With SQL you will find that the Equal operator and for that matter (even Select distinct) will not properly distinguish between a value and the same value with trailing spaces. In certain cases, you may need to do some further checking / processing (Trim, len, etc.) OR use LIKE, which follows a different process. You can look at https://stackoverflow.com/a/28682838/1662973 for more info and background.

Glad it so sorted.

Community
  • 1
  • 1
Anthony Horne
  • 2,522
  • 2
  • 29
  • 51