473,699 Members | 2,438 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

8 New Member
There is one database name as "email_book " and in that database there is one table named as "contact_book". ...name and mail_id are the two column which i had been created in that table.......now 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.......whe n 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"...... ..so for that i need coading in C#

.....please help its urgent
Feb 13 '14 #1
1 1443
audrey45
2 New Member
if you are using EF
DatabaseName db = new DatabaseName();

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

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

Similar topics

0
3984
by: Dinu | last post by:
Hi All I am trying to insert data within a transaction, into a Db2 database from asp.net. I have created a System DSN using ISeries Access Driver(32 bit) for Windows. I am then connecting to it using Microsoft .Net data provider from asp.net. I am able to insert data by using connection and comand object without
1
4131
by: Azel | last post by:
Hi, I am trying to learn ADO.net and I keep running into problems trying to insert data into my Access Database: data.mdb. here is my code: <code> // Database Variables
1
2178
by: Pratik Gupte | last post by:
I have created a database in .mdf format, but I am unable to insert data into its tables. Can anybody help how to insert data using ASP.Net 2.0 using SQL Server 2005 Express edition in windows integrated security mode. thx
3
1897
by: c676228 | last post by:
Hi all, I think I have data type problem when I tried to insert data into sql server 200. The erroe message is like this: system.invalidcastexception data type DFlage char(1) in sql 2000, DMI is depdent middile initial, char(1) in database Sex is char(1) in database, but in web page, I have "choose", "F", "M" there values.
1
2180
by: Doc11 | last post by:
I'm trying to allow users insert data into a database using the form view. But when I click the insert button I get this error: Server Error in '/Customer Database' Application. -------------------------------------------------------------------------------- Incorrect syntax near 'nvarchar'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information...
3
2736
by: Indrachapa | last post by:
I want to get how to add data to table in SQL server database using a datatable using ASP.net
3
3361
by: Surya | last post by:
Dear All, I have problem on inserting a record to database..Although it looked easy.. i have caught up with following issue .. please go ahead and help me to find solution I Need to insert records to a data base,for which i am using Typed dataSet.(I used DataSet Designer to create one) Then created a table adapter in which i have written query for INSERT , & set Database Direct property to true.(I didnt use a seperate methods for...
5
5481
by: eihabisaac | last post by:
hi i have a field in my database (status) which have the value 0 or 1 how can i update these value using check box if checked then 1 if not checked then 0 and also how to insert values using checkbox thanks for any help
0
2729
by: akshalika | last post by:
I am new to Biztalk. In my project we need to connect oracle database and insert data into oracle table using BizTalk project. I use WCF Adapter pack(SP2). I create biztalk project then using Consume Adapter Service Add-in create schemas to insert data into oracle database and tow-way send port binding file Then create orchestration and logical receive port send port, Request-response port then after correctly connect those port with message...
0
8705
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8628
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9199
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8943
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7785
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6550
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4391
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3075
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2362
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.