Wrox Programmer Forums
|
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Dreamweaver (all versions) section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 20th, 2003, 06:22 AM
Authorized User
 
Join Date: Jun 2003
Posts: 65
Thanks: 0
Thanked 0 Times in 0 Posts
Default Prevent Product Duplicates

How can I prevent a product duplicatting.

I have a page CatType.asp that submit to itself and shows at the bottom a list of products based on the CatID.
Is kind of tree view but it shows at the bottom instead under that category.

The thing is, some products are repeating because they are in the database under different cat types.

Is there any way of filtering the product <%if found do not duplicate%>?

Do you also know anywhere an function example to actually display the product under the category that belongs to - expand collapse type- as in this forum.
 
Old September 20th, 2003, 02:08 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

It depends a little on why you have the duplicates, and where you want to hide / filter them.

For example, you can use the keyword DISTINCT in an SQL query so it just returns unique records. This is a clean and quick way as it will just return the relevant records from the database, instead of passing them all.

Alternatively, you can use some loop code in ASP to accomplish this. To make this work, you duplicate records should come after each other in the recordset, so make sure you use a good ORDER BY clause to sort them correctly.
Code:
<%
  Dim OldValue
  Do While Not myRS.EOF
    If myRS("Column1") = OldValue Then
      ' Product has already been sent to the browser, so do nothing
    Else
      Response.Write(myRS("Column1"))
      myRS("Column1") = OldValue
    End If
    myRS.MoveNext()
  Loop
%>
This code prints out the value for Column1. Before it does that, it checks whether it has already been written. If not, it's value is added to the page Response, and the variable OldValue is filled with the current value from the Recordset.

You should consider the cause of the problem as well/ Should you duplicate records have been in the database in the first place?

Does this help?

Regards,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
refresh - product listing/availability tapitapovs BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 January 30th, 2008 09:53 AM
Product code generator yogeshyl Excel VBA 1 October 3rd, 2007 10:50 AM
Change image to product name zulf BOOK: Professional SQL Server 2005 Reporting Services ISBN: 0-7645-8497-9 0 June 14th, 2007 12:55 AM
A product development problem. madhukp Pro VB 6 3 December 8th, 2005 01:44 PM
Validation to Prevent Duplicates Roly Reefer Access VBA 1 August 19th, 2005 08:21 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.