Click to See Complete Forum and Search --> : [RESOLVED] Trouble comparing strings from a DB


maitopoika
August 27th, 2009, 11:43 AM
So i am trying to compare a string from a DB to another string that i code in.
I keep getting a false when they strings look the same, they are both "Admin"
can you see what I am doing wrong?

private void UserRedirect(string UserType)
{

string AdminString = "Admin";
bool b = AdminString == UserType;
LBLError.Text = b.ToString() + AdminString+UserType;
}



the output to the label here is
False Admin Admin

not sure why it is saying false when they look the same

here is where i am calling this function

....
loginType = myEmployee.loginType; //i have confirmed that this is "Admin"

UserRedirect(loginType);




any help would be great. thanks!

maitopoika
August 27th, 2009, 11:53 AM
Sorry guys I figured it out.
I needed to apply .trim() to the string comming from the DB and it compared just fine