CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2008
    Location
    Suomi Finland
    Posts
    47

    [RESOLVED] Trouble comparing strings from a DB

    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?
    Code:
      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
    Code:
    ....
                   loginType = myEmployee.loginType; //i have confirmed that this is "Admin"
                  
                   UserRedirect(loginType);
    any help would be great. thanks!

  2. #2
    Join Date
    Sep 2008
    Location
    Suomi Finland
    Posts
    47

    Re: Trouble comparing strings from a DB

    Sorry guys I figured it out.
    I needed to apply .trim() to the string comming from the DB and it compared just fine

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured