473,499 Members | 1,716 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to prevent storing duplicate values

In ASP.NET 2.0 project, I have added a dataset and have setup the datatable
and configured the datatableadapter (using the wizards).

In my code I can use the mytableadapter.insert method to insert a new record
in the table.

How do I check if the key column value being inserted this time already
exists and hence prompt the user the message ("userid already exists" or
"email address already exists")

Thanks,

Feb 15 '08 #1
2 2767
You can use the DataTable.Select() method to search for the userid in the
datatable if it exists then show error message otherwise insert
another option would be to create a unique index on the userid column
DataTable.Columns["ColumnName"].Unique = true;

--
Misbah Arefin

"dotpro2008" wrote:
In ASP.NET 2.0 project, I have added a dataset and have setup the datatable
and configured the datatableadapter (using the wizards).

In my code I can use the mytableadapter.insert method to insert a new record
in the table.

How do I check if the key column value being inserted this time already
exists and hence prompt the user the message ("userid already exists" or
"email address already exists")

Thanks,
Feb 15 '08 #2
sorry to RE: on my own post but if your original intent was that the dattable
is empty and you are inserting a new row and wanted to check it against the
db rows then you would have to execute some SP which would seach the db table
for that value and return a scalar value indicating if the data exists or not

--
Misbah Arefin

"Misbah Arefin" wrote:
You can use the DataTable.Select() method to search for the userid in the
datatable if it exists then show error message otherwise insert
another option would be to create a unique index on the userid column
DataTable.Columns["ColumnName"].Unique = true;

--
Misbah Arefin

"dotpro2008" wrote:
In ASP.NET 2.0 project, I have added a dataset and have setup the datatable
and configured the datatableadapter (using the wizards).

In my code I can use the mytableadapter.insert method to insert a new record
in the table.

How do I check if the key column value being inserted this time already
exists and hence prompt the user the message ("userid already exists" or
"email address already exists")

Thanks,

Feb 15 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
4132
by: jeff brubaker | last post by:
Hello, Currently we have a database, and it is our desire for it to be able to store millions of records. The data in the table can be divided up by client, and it stores nothing but about 7...
9
14551
by: Catherine Jo Morgan | last post by:
Can I set it up so that a certain combination of fields can't contain the same entries, on another record? e.g. a combination of FirstName/LastName/address? Or FirstName/LastName/phone? Or...
6
4085
by: Arthur Dent | last post by:
Anyone know, in VB.NET (2005) how to prevent duplicate occurrences of the same event handler on an event? e.g... I have some object which raises an event, and some other class which consumes...
4
18127
by: =?Utf-8?B?QXNhZg==?= | last post by:
Hi, How can I prevent from an ASP.NET page to resend all the data again when the user press the Refresh button or F5 on the browser? Thanks in advanced, Asaf
6
4528
by: teser3 | last post by:
I have my PHP inserting into Oracle 9i. But how do I prevent duplicate record entries? I only have 3 fields in the insert in the action page: CODE <?php $c=OCILogon("scott", "tiger",...
1
3379
by: chicago1985 | last post by:
I have a unique constraint in my Oracle table for 3 fields. If I enter duplicate info on the table using Oracle client I will get an Ora message error ORA-00001 that tells me it is a duplicate entry...
0
1958
by: jehrich | last post by:
Hi Everyone, I am a bit of a hobby programmer (read newbie), and I have been searching for a solution to a SQL problem for a recent pet project. I discovered that there are a number of brilliant...
1
4993
by: Rocker1 | last post by:
Hello guys, I am reading a downloaded textfile which has a fields like date,NAV and Name using VB.NET. The date on which the textfile is downloaded remains the same.After each readline operation...
5
3642
by: Eric | last post by:
Hi, the user gets a form to fill. All the filled values are put into session variables. I want to prevent that he could click to the previous arrow of the browser and then comes back to the...
2
3576
by: aeblank | last post by:
THE PROBLEM I'm running into performance issues generating and storing a randomly created graph in a SQL Server database. I have a T-SQL script that generates a graph, and then randomly connects the...
0
7128
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,...
0
7215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6892
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...
0
7385
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5467
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,...
1
4917
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...
0
4597
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
1
661
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
294
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.