By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,140 Members | 1,361 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,140 IT Pros & Developers. It's quick & easy.

how to avoid to insert same data into database using C#

P: 8
There is one database name as "email_book" and in that database there is one table named as "contact_book" and mail_id are the two column which i had been created in that i want to add data into to my table using form in C# but on the counter part i just want to avoid inserting the repeated data into the table.......when user add same mail_id which is already present in the table then it must gives the message that "this mail_address is already present in database" for that i need coading in C#

.....please help its urgent
Feb 13 '14 #1
Share this Question
Share on Google+
1 Reply

P: 2
if you are using EF
DatabaseName db = new DatabaseName();

var checkMail = db.TableName.Single(d => d.mail_id == userMailId);
if(checkMail == null){
//Save your email
//Message: email is already exist
Feb 13 '14 #2

Post your reply

Sign in to post your reply or Sign up for a free account.