Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2006

    Unanswered: Avoid duplication error

    I am wondering if there is any sort of code/SQL that could make a user aware that if he/she enters a GameId number into a text box that this number is already in use. If this number was to be used again it cause a duplication to the underlying table?
    For example if a record was to be entered and the following numbers were already recorded 1,2,3,4,5,6,7,8 and a user entered the number 8, could the user be made aware (possibly from the LostFocus event of a text box) that this number is already in use?

    Any suggestions would be gratefully received.
    Regards Peter Taylor

  2. #2
    Join Date
    Feb 2004
    In front of the computer
    Provided Answers: 54
    You bet! A simple SELECT for the key value should tell you if it is in use or not. If the returned recordset is empty, then the new number is fine. If rows are returned, then the number is already in use..

    As this question strikes me to be more of a Visual Basic question than a SQL question, I'm going to move this thread to the Visual Basic forum. There may be a VB specific option that is even simpler, and one of the folks there may be able to give you better suggestions than I can.


Posting Permissions

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