Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics 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 January 17th, 2008, 04:34 PM
Authorized User
 
Join Date: Jan 2008
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default repeating data

I have a quick question... elementary to you seasoned asp'ers Im sure. I have a form that I am using to give a band name. This asp block of code is supposed to then connect to sql and grab the albums this band has released. What is happening though is it lists the album, artists and year for each album but it lists it like 12 times (how ever many songs are in that album is how many times it lists it)
Not sure how to tell it i only want unique instances of each album? Any ideas? Thank you!

<%
  option explicit
  Dim strConnect
%>

<!-- METADATA TYPE="typelib"
              FILE="C:\Program Files\Common Files\System\ado\msado15.dll" -->
<HTML>
<HEAD>
<TITLE>Using the Find Method to find an Artists Albums</TITLE>
</HEAD>
<BODY>

<%
  Dim strArtist, strCriteria
  strArtist = Request.Form("artist")

  Dim objRS
  Set objRS = Server.CreateObject("ADODB.Recordset")
  objRS.Open "top50000", strConnect, adOpenStatic, adLockReadOnly, adCmdTable

  strCriteria = "artist='" & strArtist & "'"

  objRS.Filter = strCriteria

While Not objRS.EOF
        Response.Write "<H2>Released by " & strArtist & ":</H2>" & _
         "<B>Album:</B> " & objRS("Album") & "<BR>" & _
         "<B>Artist:</B> " & objRS("Artist") & "<BR>" & _
         "<B>Year:</B> " & objRS("Year") & "<BR><BR><BR>"
objrs.movenext
wend

  objrs.close
  set objrs = nothing
%>
</BODY>
</HTML>
__________________
keep your kneeze in the breeze
 
Old January 17th, 2008, 05:44 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

This isn't an asp question it is a SQL question.

Your query should be something like:

SELECT DISTINCT Artist, Albumn, Year FROM <Table>

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor :.
Wrox Books 24 x 7
================================================== =========
 
Old January 18th, 2008, 10:02 AM
Authorized User
 
Join Date: Jan 2008
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thank you dparsons for clarifying... i wasnt sure if i could get just the specific records using asp... guess i can not.
 
Old January 18th, 2008, 12:03 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Well that is really a different question. The way you posed your question is that a user of your site will select a band and then you will display information based off of X band.

So you can do this 2 ways, the most effecient being through SQL:
SELECT DISTINCT Albumn, Year FROM <table> where artist = '<someartist>'

You can, however, return all of the data from your table and then use the recordsets Filter property to only get the data you want:

objrs.Filter = "Artist = 'some artist'"

Does that clear things up a bit better?

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor :.
Wrox Books 24 x 7
================================================== =========
 
Old January 18th, 2008, 12:11 PM
Authorized User
 
Join Date: Jan 2008
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It does thanks so much for the quick responses dparsons. Both ways worked! :D
 
Old January 18th, 2008, 12:34 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

No problem, glad it worked out for you.

-Doug

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor :.
Wrox Books 24 x 7
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
Gridview/repeating data Mogg-Way ASP.NET 2.0 Basics 15 July 18th, 2007 02:53 PM
repeater repeating in horizontal (data in 2 colums gbianchi ASP.NET 2.0 Professional 0 April 11th, 2007 11:08 AM
Repeating Region DynaCube Classic ASP Basics 0 January 12th, 2007 11:26 PM
Repeating Records Nicky_uk Classic ASP Databases 7 February 2nd, 2005 05:41 PM
Repeating textboxes Robert_Hill BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 0 September 2nd, 2004 10:42 AM





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