Solved

how to avoid Duplicate when you insert record

Posted on 2011-03-19
4
399 Views
Last Modified: 2012-05-11
Am trying to insert a record pulled out from Active Directory but i can see so many duplicates,how can i avoid when i insert those records.

for eg

will.smith@gmail.com repeat 5 times,i just don't want to insert a duplicate record based on mail id.

any one pleas enlighten me.

Thanks in Advance
0
Comment
Question by:Sha1395
  • 2
4 Comments
 
LVL 2

Accepted Solution

by:
ramkihardy earned 250 total points
ID: 35171208
simple you can set the maildid column unique in the table which you want to enter.......
when you try to insert a duplicate email id..it throws an error...catch that error it consist of errorid for duplicate record insertion...you can check if duplicate record inserted in catch...like
if(errid=="error id for duplicate record insertion")
{
Messagebox.show("Record alreadyb exist");
}
2.Otherwise you have to select the distinct record so that it wont contain any duplication...
Regards
Ramki
0
 
LVL 3

Assisted Solution

by:exceter
exceter earned 250 total points
ID: 35171233
Also you can create a temporary table and insert there initially with INSERT INTO .... SELECT DISTINCT EmailID...
0
 

Author Comment

by:Sha1395
ID: 35171548
Thanks Ramki and Exceter.

As you people mentioned i make Email Id is a primary key and use TRY  Catch in my code.its done.

Thanks again for all your help
0
 
LVL 2

Expert Comment

by:ramkihardy
ID: 35171602
Please mark it as accepted solution...
Thanks & regards
Ramki
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
String manipulation 15 64
ADO.NET ENTITY DATA MODEL 3 30
Server Error 11 47
ASP.NET 5 Templates 2 65
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
A short film showing how OnPage and Connectwise integration works.

947 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now