Results 1 to 7 of 7

Thread: detecting same records

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2006
    Posts
    84

    detecting same records

    can anyone help me with this... i am trying to add new record and my problem is what if theres the same record in my database how can i avoid that...

    example im adding applicant with applicant id 0001 then im going o add a new one and accidentally i input and applicant id 0001what will i do to not to add that.

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091

    Re: detecting same records

    You should setup up your database tables correctly with primary keys, then its just a matter of trapping the error that occurs when you try to add a duplicate key in the program.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    Re: detecting same records

    You can do like the previous poster said or you can run a quick query on your table looking for the ID you are trying to enter. Then return a boolean value if it is there or not.

  4. #4
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091

    Re: detecting same records

    Quote Originally Posted by Besoup
    You can do like the previous poster said or you can run a quick query on your table looking for the ID you are trying to enter. Then return a boolean value if it is there or not.
    True, however primary keys are there for a reason. It would be considered 'more correct' to set up keys, because even if you were manually entering the data into the table (through the SQL Server interface or Access, etc) the keys would prevent accidental duplicates, where as being dependent on the program would not.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  5. #5
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    Re: detecting same records

    I agree with your method.. was just offering a work around.

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Nov 2006
    Posts
    84

    Re: detecting same records

    i already have the primary key. can u give me an example program about ths

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: detecting same records

    Quote Originally Posted by mheiy
    i already have the primary key. can u give me an example program about ths
    Here is the example.
    Quote Originally Posted by crptcblade
    You should setup up your database tables correctly with primary keys, then its just a matter of trapping the error that occurs when you try to add a duplicate key in the program.
    Just trap the error when it occurs and display an appropriate message box.

Posting Permissions

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



Click Here to Expand Forum to Full Width