Recordset Retrieval Problem

Results 1 to 2 of 2

Thread: Recordset Retrieval Problem

  1. #1
    JvG Guest

    Default Recordset Retrieval Problem

    I&#039m doing a query (name, link) on the following 3 tables, where ITEMS.ID = 1. <BR><BR>ITEMS<BR>ID name<BR>1 blah1<BR>2 blah2<BR><BR>ITEM_CAT<BR>ID CatID<BR>1 1<BR>1 2<BR>2 2<BR><BR>CAT<BR>CatID link<BR>1 image1<BR>2 image2 <BR><BR>This would obviously give me this result:<BR><BR>name link<BR>blah1 image1<BR>blah1 image2<BR><BR>I use this simple piece of code to read and display the results:<BR><BR>Do Until objRS.EOF = True<BR> Response.Write "&#060;b&#062;Name: &#060;/b&#062;" & objRS("name")<BR> Response.Write "&#060;b&#062;images: &#060;/b&#062;" & objRS("link")<BR> objRS.MoveNext<BR>Loop <BR><BR>The problem is that rather than returning the record only once, it&#039s printed on the page twice, each one with a different image. Obviously I don&#039t want that. I want the name to be printed only once, with both images below it.<BR><BR>Been breaking my head over this problem all day, but still haven&#039t figured out how to do this. Can anyone offer a hand?

  2. #2
    sm549 Guest

    Default RE: Recordset Retrieval Problem

    Probably dozens of ways to do it, but assuming an ORDER BY name in the query, you could avoid printing the name if it was the same as the previous one.<BR><BR>Dim sName, sPrevName<BR>sPrevName = ""<BR>Do Until objRS.EOF = True<BR>&nbsp&nbspsName = Trim(objRS("name"))<BR>&nbsp&nbspIf sName &#060;&#062; sPrevName<BR>&nbsp&nbsp&nbsp&nbspResponse.Write "&#060;b&#062;Name: &#060;/b&#062;" & sName<BR>&nbsp&nbspEnd If<BR>&nbsp&nbspResponse.Write "&#060;b&#062;images: &#060;/b&#062;" & objRS("link")<BR>&nbsp&nbspsPrevName = sName<BR>&nbsp&nbspobjRS.MoveNext<BR>Loop <BR><BR>HIH

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts