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. General Programming
  3. C#
  4. user name and password

user name and password

Scheduled Pinned Locked Moved C#
6 Posts 3 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
    Mads115
    wrote on last edited by
    #1

    Hi In my login form i have set user name Password as "admin" and "sa" if i type ADMIN and SA it should not work but its working.. how resolve it thanks in advance

    A S 2 Replies Last reply
    0
    • M Mads115

      Hi In my login form i have set user name Password as "admin" and "sa" if i type ADMIN and SA it should not work but its working.. how resolve it thanks in advance

      A Offline
      A Offline
      Abhijit Jana
      wrote on last edited by
      #2

      Mads115 wrote:

      In my login form i have set user name Password as "admin" and "sa" if i type ADMIN and SA it should not work but its working.. how resolve it

      How did you checking the use id and password? Where is the code? Did you check with String.Equal() or what ?

      cheers, Abhijit CodeProject MVP Web Site:abhijitjana.net

      M 1 Reply Last reply
      0
      • M Mads115

        Hi In my login form i have set user name Password as "admin" and "sa" if i type ADMIN and SA it should not work but its working.. how resolve it thanks in advance

        S Offline
        S Offline
        saanj
        wrote on last edited by
        #3

        Check out the following code: if (string.Compare("hello", "Hello", false) == 0) { //do whatever you wish } The third parameter makes the string comparison case sensitive. Regards Saanj

        Either you love IT or leave IT...

        1 Reply Last reply
        0
        • A Abhijit Jana

          Mads115 wrote:

          In my login form i have set user name Password as "admin" and "sa" if i type ADMIN and SA it should not work but its working.. how resolve it

          How did you checking the use id and password? Where is the code? Did you check with String.Equal() or what ?

          cheers, Abhijit CodeProject MVP Web Site:abhijitjana.net

          M Offline
          M Offline
          Mads115
          wrote on last edited by
          #4

          this is the Code I am using SqlConnection Con1 = new SqlConnection("server=.;database=ab;uid=sa;pwd=max"); Con1.Open(); SqlCommand cmd1 = new SqlCommand("select UserName,Password from mads Where Username= '" + usrtxt.Text + "' and Password ='" + passtxt.Text + "'", Con1); SqlDataReader dr = cmd1.ExecuteReader(); dr.Read(); if (dr.HasRows == true) { prj = new Project_Details(usrtxt.Text); prj.Show(); } dr.close;

          S A 2 Replies Last reply
          0
          • M Mads115

            this is the Code I am using SqlConnection Con1 = new SqlConnection("server=.;database=ab;uid=sa;pwd=max"); Con1.Open(); SqlCommand cmd1 = new SqlCommand("select UserName,Password from mads Where Username= '" + usrtxt.Text + "' and Password ='" + passtxt.Text + "'", Con1); SqlDataReader dr = cmd1.ExecuteReader(); dr.Read(); if (dr.HasRows == true) { prj = new Project_Details(usrtxt.Text); prj.Show(); } dr.close;

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

            SQL is case insensitive. You have to force SQL to turn on the case sensitivity for the select query. Just add the following clause with your select query: COLLATE SQL_Latin1_General_CP1_CS_AS Use COLLATE SQL_Latin1_General_CP1_CI_AS for case insensitivity. It can solve your problem. Regards Saanj

            Either you love IT or leave IT...

            1 Reply Last reply
            0
            • M Mads115

              this is the Code I am using SqlConnection Con1 = new SqlConnection("server=.;database=ab;uid=sa;pwd=max"); Con1.Open(); SqlCommand cmd1 = new SqlCommand("select UserName,Password from mads Where Username= '" + usrtxt.Text + "' and Password ='" + passtxt.Text + "'", Con1); SqlDataReader dr = cmd1.ExecuteReader(); dr.Read(); if (dr.HasRows == true) { prj = new Project_Details(usrtxt.Text); prj.Show(); } dr.close;

              A Offline
              A Offline
              Abhijit Jana
              wrote on last edited by
              #6

              Mads115 wrote:

              SqlCommand cmd1 = new SqlCommand("select UserName,Password from mads Where Username= '" + usrtxt.Text + "' and Password ='" + passtxt.Text + "'", Con1);

              If this is your live code, Please be careful about SQL Injection.

              cheers, Abhijit CodeProject MVP Web Site:abhijitjana.net

              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