473,623 Members | 2,433 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 datatableadapte r (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 2771
You can use the DataTable.Selec t() 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.Colum ns["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 datatableadapte r (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.Selec t() 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.Colum ns["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 datatableadapte r (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
4140
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 integers. | table | | id | clientId | int1 | int2 | int 3 | ... | Right now, our benchmarks indicate a drastic increase in performance if we divide the data into different tables. For example,...
9
14571
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 FirstName/LastName/email? Or is it possible to allow this but to throw up an alert message? Warning that this person is probably already in the database? TIA
6
4092
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 them. So in essence what I want to do is something like this in the consumer class... If Not objEventSource.SomeEvent.Handlers.Contains(AddressOf me.EventHandler) Then _ AddHandler objEventSource.SomeEvent, AddressOf me.EventHandler
4
18134
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
4540
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", "orcl"); if ( ! $c ) { echo "Unable to connect: " . var_dump( OCIError() );
1
3383
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 attempt. How do I capture that in my PHP page if someone tries to enter duplicate record info? My PHP Oracle insert statement in the action page: $s = OCIParse($c, "insert into tableOne values ('$varOne', '$varTwo', '$varThree')");...
0
1964
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 minds hanging around here, and I was hoping someone could point me in the right direction. I'm using MS SQL 2005 and I have created a table of "level changes" that basically stores the device name , the previous level and the new level along...
1
5012
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 it looks into the Access DB (tablename:Details) and updates the 3 columns(Date,NAV,Name).My question is how do i prevent the user accesing the already downloaded file or in other words how do i prevent my DB being loaded with duplicate values in...
5
3651
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 form. Is that possible with asp.net? Or, is it possible to clear the session when leaving the form page by clicking the previous arrow?
2
3584
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 vertices in that graph to each other. I can see that my hard-drive is working very hard throughout the operation. The operation took about 2 hours (I just canceled it at this point, looked like it was about 10% done) with 200,000 vertices and an...
0
8670
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
8326
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
7150
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
6106
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
5561
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4074
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...
0
4164
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2602
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
1
1778
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.