RSSIAdmin
asked on
Prevent Duplicate Records on "Insert" .NET 2.0 Detailsview web application
Hi Expert:
I have a .NET 2.0 guestbook like application that untilizes a std "DetailsView" control webpage ( ) .
User enter's his or her name, email address and employee# and clicks a button labelled "INSERT"
to enter "sign-up" data record ( one at a time) into the SQL Server.
THe only code is one simple "INSERT INTO TABLE .......... firstname,lastname, etc "
The problem here is the user can possiblily add themselves more then once to the guest list.
How do the pro's prevent duplicate records entering in SQL server.
Is there something simple that can be done to prevents ( a key on database etc) .
What do I have to do here to prevent possible duplicate records?
Help.
I have a .NET 2.0 guestbook like application that untilizes a std "DetailsView" control webpage ( ) .
User enter's his or her name, email address and employee# and clicks a button labelled "INSERT"
to enter "sign-up" data record ( one at a time) into the SQL Server.
THe only code is one simple "INSERT INTO TABLE .......... firstname,lastname, etc "
The problem here is the user can possiblily add themselves more then once to the guest list.
How do the pro's prevent duplicate records entering in SQL server.
Is there something simple that can be done to prevents ( a key on database etc) .
What do I have to do here to prevent possible duplicate records?
Help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
My 1 single table looks something like this:
Table 1
(primary key) person_ID int
First_Name varchar(50)
Last_Name varchar(50)
Pay_Number varchar(50) <--------- one unique paynumber per person
etc.. etc..
Using --> Pay_Number (unique paynumber per person)
WOULD MY INSERT STATEMENT LOOK LIKE THE FOLLOWING ( my user input textbox values @First_Name,...@Pay_Number
INSERT INTO Table_1 (First_Name, Last_Name,........etc) VALUES (@First_Name,(@Last_Name,.
WHERE NOT EXIST (SELECT Pay_Number FROM Table_1 WHERE person_ID = 'Pay_Number')
Sorry I am not a DB person, could you kindly please look over above and advise if this is what you mean!!!
Again, thank you (please advise)
ASKER
Thank you aneeshattingal for your welcomed advise
However, I still not sure if the following is correct ?
INSERT INTO Table_1 (First_Name, Last_Name,........etc) VALUES (@First_Name,(@Last_Name,. ..@Pay_Num ber)
WHERE NOT EXIST (SELECT Pay_Number FROM Table_1 WHERE person_ID = 'Pay_Number')
Again, thank you
However, I still not sure if the following is correct ?
INSERT INTO Table_1 (First_Name, Last_Name,........etc) VALUES (@First_Name,(@Last_Name,.
WHERE NOT EXIST (SELECT Pay_Number FROM Table_1 WHERE person_ID = 'Pay_Number')
Again, thank you
ASKER
I think I understand but just to make sure.
My 1 single table looks something like this:
Table 1
(primary key) person_ID int
First_Name varchar(50)
Last_Name varchar(50)
Pay_Number varchar(50) <--------- one unique paynumber per person
etc.. etc..
Using --> Pay_Number (unique paynumber per person)
WOULD MY INSERT STATEMENT LOOK LIKE THE FOLLOWING
INSERT INTO Table 1 (First_Name, Last_Name,........etc
WHERE NOT EXIST (Pay_Number = @userinputpaynumber)
Sorry I am not a DB person, could you kindly please look over above and advise if this is what you mean
Again, thank you (please advise)