Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 19th, 2006, 05:40 AM
Friend of Wrox
 
Join Date: May 2006
Location: Northampton, United Kingdom.
Posts: 107
Thanks: 1
Thanked 8 Times in 7 Posts
Default Checking for Duplicates

Hi,

Does anyone have a solution to the problem of preventing duplicate records when adding records to a separate table?

I would like to display a grid view of products and allow the user to click a button on a row and add that product to a wish list table.
Before the record is inserted I would like to check that the item has not already been inserted.

If anyone has a solution or knows of a decent tutorial I would be very grateful.

Thanks


__________________
Try our latest project www.nobanx.com Currency Exchange for members
  #2 (permalink)  
Old July 19th, 2006, 11:05 AM
Authorized User
Points: 333, Level: 6
Points: 333, Level: 6 Points: 333, Level: 6 Points: 333, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2005
Location: Fresno, California, USA.
Posts: 94
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Only way to do this is by code. You will have to query (with COUNT()) the table for the fields entered with the WHERE clause checking on each field to see if any rows match what the user inputted. If count is greater than "0" then you have a duplicate entry. Hard part about that is if they word it differently you will still get duplicates just worded differently.
  #3 (permalink)  
Old July 20th, 2006, 08:41 AM
Friend of Wrox
 
Join Date: May 2006
Location: Northampton, United Kingdom.
Posts: 107
Thanks: 1
Thanked 8 Times in 7 Posts
Default

Thanks for your answer.

Another suggestion from someone was


Just do a;

SELECT ProductID FROM WishListTable WHERE ProductID = <selected Product ID>
If you don't get an empty result set back you know the product is already there. Or if you are using SQL Server Stored Procedures;


IF NOT EXISTS (SELECT 1 FROM WishListTable WHERE ProductID = <selected Product ID>)
    INSERT INTO WishListTable
    ...


These set me looking for tutorials and I found one at http://aspalliance.com/687

I've incorporated these suggestions and the tutorial into my system and it works a treat

Thanks again



 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Yes to duplicates MMJiggy62 Beginning VB 6 3 July 14th, 2006 11:51 AM
Checking for duplicates toedipper2 SQL Server 2000 3 June 7th, 2006 03:50 PM
Duplicates in XSLT d_sathish XSLT 1 November 9th, 2005 11:45 AM
checking for duplicates jammykam Access 3 October 2nd, 2003 08:06 PM
Duplicates ashley_y Access 11 August 14th, 2003 03:41 PM



All times are GMT -4. The time now is 12:49 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.