Check if user exists

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • KothuriKavitha
    New Member
    • May 2008
    • 2

    Check if user exists

    please give me for this "when user creates new account ,when he enter his username ,it must check with database and if user already exits with same name,must give message that user exits".
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    if the data is stored in database use COUNT to findout if the entry already exists.

    Comment

    • kunal pawar
      Contributor
      • Oct 2007
      • 297

      #3
      Right, count users with same using Executescalar function, and then prompt appropriate message

      Comment

      • malav123
        New Member
        • Feb 2008
        • 217

        #4
        Hi,

        You can fetch querry at the time of submit button click and compare the value of username textbox with the field of database, if it exists then prompt the user that "user name already exists"...

        Comment

        • Frinavale
          Recognized Expert Expert
          • Oct 2006
          • 9749

          #5
          Originally posted by KothuriKavitha
          please give me for this "when user creates new account ,when he enter his username ,it must check with database and if user already exits with same name,must give message that user exits".
          What have you tried so far?
          Do you know how to Use a database in your Application?

          -Frinny

          Comment

          • castron
            New Member
            • Mar 2008
            • 5

            #6
            try this:

            SqlCommand sqlCount = myConnection.Cr eateCommand();
            sqlCount.Comman dText = "SELECT COUNT(*) FROM tablename WHERE UserName = '" + aUserName + "'";
            int recCount = (int)sqlCount.E xecuteScalar();


            if (recCount == 0) // no existing record for username
            {
            insert record
            }
            else
            {
            user already exist
            }

            Comment

            Working...