Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. How to compare values

How to compare values

Scheduled Pinned Locked Moved ASP.NET
databasequestion
7 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    miniThomas
    wrote on last edited by
    #1

    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

    G F S 4 Replies Last reply
    0
    • M miniThomas

      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

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      You can use the string.Compare method to specify if the comparison should be case sensetive or not. Usually the comparison for user name is not case sensetive, but the password is.

      --- b { font-weight: normal; }

      1 Reply Last reply
      0
      • M miniThomas

        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

        F Offline
        F Offline
        Faisal Khatri
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • M miniThomas

          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

          F Offline
          F Offline
          Faisal Khatri
          wrote on last edited by
          #4

          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

          S 1 Reply Last reply
          0
          • F Faisal 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

            S Offline
            S Offline
            shreekar
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            • M miniThomas

              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

              S Offline
              S Offline
              Suresh Pirsquare
              wrote on last edited by
              #6

              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!

              M 1 Reply Last reply
              0
              • S Suresh Pirsquare

                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!

                M Offline
                M Offline
                miniThomas
                wrote on last edited by
                #7

                Thanks to all.. All ur replies r working fine... Thanks, Mini

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups