|
-
Feb 13th, 2007, 07:56 AM
#1
Thread Starter
Lively Member
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.
-
Feb 13th, 2007, 08:05 AM
#2
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
-
Feb 13th, 2007, 08:21 AM
#3
Frenzied Member
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.
-
Feb 13th, 2007, 08:53 AM
#4
Re: detecting same records
 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
-
Feb 13th, 2007, 08:55 AM
#5
Frenzied Member
Re: detecting same records
I agree with your method.. was just offering a work around.
-
Feb 13th, 2007, 09:19 AM
#6
Thread Starter
Lively Member
Re: detecting same records
i already have the primary key. can u give me an example program about ths
-
Feb 13th, 2007, 10:13 AM
#7
Re: detecting same records
 Originally Posted by mheiy
i already have the primary key. can u give me an example program about ths
Here is the example.
 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|