Results 1 to 12 of 12

Thread: checking duplicate values in my database?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2004
    Posts
    27

    checking duplicate values in my database?

    Hello,

    i've made a programe where i need to add new users, i would like it so that if a user has the same name as someone in mu db, then it will not allow that entry?

    Thanks

    Homer S

  2. #2
    Fanatic Member
    Join Date
    May 2002
    Posts
    746
    It is of course possible that you could have two users with the same name but...

    Run a query against the db for the new user name before you run your insert. If the query comes back with one or more results inform the user that a record already exists.

  3. #3
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950
    That's more a database issue than a vb issue. Depending on your db, you could set the name as a primary key (identity in SQL Server, I think), or just disallow duplicate values.

  4. #4
    Fanatic Member
    Join Date
    May 2002
    Posts
    746
    Name as a PK is a bad idea - not really guaranteed to be unique. Doesn't take too big a user list to need two "Smith" entries.

  5. #5
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950
    Yeah, but if he disallows duplicates, it works like a primary key anyway.

  6. #6
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    Hi Homer,

    I don't see how you can avoid duplicate names. That is why most businesses identify customers by a unique number.

    Perhaps you should use an Autonumber column to cross identify your customer names.
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  7. #7
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Originally posted by salvelinus
    Yeah, but if he disallows duplicates, it works like a primary key anyway.
    Yea, but deep down, you know you wouldn't do it that way.

  8. #8
    Member
    Join Date
    Aug 2003
    Posts
    51
    Yes what you need is IDnumber as the primary key. To filter out you should check their name against their address.

    Regards

  9. #9
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    Hi,

    "To filter out you should check their name against their address."

    This takes great care as any minor difference in entering an address would result in a mismatch. It is easier to check firstly on Surname then (if a match is found) Forename then (if a match is found) second forename etc then (if a match is found) postecode (Zip Codes to the Yanks) and then (if a match is found) house number/name.
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  10. #10
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950
    Originally posted by nemaroller
    Yea, but deep down, you know you wouldn't do it that way.
    That's true, but I wouldn't disallow duplicate names, either. Maybe in a role playing game, where you don't want two Merlins or something.

  11. #11
    Member
    Join Date
    Feb 2004
    Location
    LA
    Posts
    57
    Hello,

    Like the guys say if you what to prevent duplicate during data entry you need to create primary key and enforce No duplicates.

    But if you what to check your DB for existing Duplicate records try running this Query

    Code:
    SELECT Value1, Value2 FROM TableName WHERE Value3 IN (SELECT Value3 FROM TableName GROUP BY Value3 HAVING COUNT(*)  > 1)
    Where Value3 – the field that you think has duplicates

    Good luck

  12. #12
    Member
    Join Date
    Aug 2003
    Posts
    51
    Originally posted by taxes
    Hi,

    "To filter out you should check their name against their address."

    This takes great care as any minor difference in entering an address would result in a mismatch. It is easier to check firstly on Surname then (if a match is found) Forename then (if a match is found) second forename etc then (if a match is found) postecode (Zip Codes to the Yanks) and then (if a match is found) house number/name.
    Yes, it's a matter of using the English language and I'm not good at it. However, the thing is, as I did mentioned about using IDnumber.

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