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. Database & SysAdmin
  3. Database
  4. 3 database questions

3 database questions

Scheduled Pinned Locked Moved Database
databasequestionannouncement
3 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.
  • C Offline
    C Offline
    Chodici Mrkev
    wrote on last edited by
    #1

    Hi, I have a SQL database with usernames and passwords. 1)Now I need find a user name (which user wrote into textbox) and prove the password. 2)I have a registration page, it works well, but I would like to search the database before I add the new record to it, (no duplicity) 3)How can I delete a record? (update record) Thanks very much for your answer

    C C 2 Replies Last reply
    0
    • C Chodici Mrkev

      Hi, I have a SQL database with usernames and passwords. 1)Now I need find a user name (which user wrote into textbox) and prove the password. 2)I have a registration page, it works well, but I would like to search the database before I add the new record to it, (no duplicity) 3)How can I delete a record? (update record) Thanks very much for your answer

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      None of these questions can be answered without knowing the schema of your database, you should be able to answer them all from the books online, and this smells like homework :-) Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

      1 Reply Last reply
      0
      • C Chodici Mrkev

        Hi, I have a SQL database with usernames and passwords. 1)Now I need find a user name (which user wrote into textbox) and prove the password. 2)I have a registration page, it works well, but I would like to search the database before I add the new record to it, (no duplicity) 3)How can I delete a record? (update record) Thanks very much for your answer

        C Offline
        C Offline
        Colin Angus Mackay
        wrote on last edited by
        #3

        1. For security you should always store the passwords in an encrypted form. When the user registers for the first type encrypt the password. When the user logs in on subsequent sessions encrypt the password again and search for the encrypted version of the password.

        SELECT COUNT(*) FROM myRegistrationTable WHERE UserName=@userName AND EncryptedPassword=@encryptedPassword

        The above code will return 0 if the user name and password cannot be found, or 1 otherwise. If it returns any other value the database contains duplicate information. 2. You can apply a unique constraint to the table to ensure that no duplicates are entered. Also the primary key is by default a unique value - so sufficient uniqueness may already be covered. If you do this SQL Server will raise an error when you perform your insert and you can pick this up in your .NET application by catching the SqlException that is generated. You could also write a stored procedure that checks for the existance of a record first then conditionally inserts the new record if there isn't one already. 3. Use the DELETE command. Does this help?


        "If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!

        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