asp producing duplicate results

Discussion in 'C#' started by barnet, Feb 5, 2009.

  1. #1
    Hi

    Can you help me?

    I have a problem of duplication of records and am not sure how to reword the scripting.

    I have a business section to a site I am building that displays the categories and discriptions of the services a particular business provides from information gathered from the database.

    The page I am talking about is at
    http://www.youfindit.co.nz/business.asp?busid=12

    as you can see the title is (eg: massage) is repeating down the page. How do I reword hte scripting to prevent this. Or is it how I have structured the database.

    Would appreciate any feedback.
    
    <%
    set GalConn3=Server.CreateObject("ADODB.Connection")
    GalConn3.Open Connect_String
    
    dim adoRs4
    set adoRs4 = Server.CreateObject("ADODB.Recordset")
    strSQL4 = "Select DISTINCT * From businesscategories, subcategory where busid2=" & intbusID & " and businesscategories.bussubcatid=subcategory.subid "
    
    'response.Write(strSQL4)
    'response.End
    set adoRs4 = galConn3.Execute(strSQL4)
      
                     If not adoRs4.EOF then
        do while not adors4.eof 
        
          %>
    <tr>
    <td width="70%" class="contentsml">
    <b><%=adoRs4("subcatname")%></b>
    </td></tr>
     <%
     set GalConn4=Server.CreateObject("ADODB.Connection")
    GalConn4.Open Connect_String
    
     set adoRs5 = Server.CreateObject("ADODB.Recordset")
    strSQL5 = "Select * From businesscategories where bussubcatid=" & adoRs4("subid") 
    'response.Write(strSQL5)
    'response.End
    set adoRs5 = galConn4.Execute(strSQL5)
    %>
      <%
        If not adoRs5.EOF then
        do while not adors5.eof 
      %>       
                    <tr><td class="contentsml" >                                     
    &nbsp; &nbsp;<%=adoRs5("busservice")%></td>
    <td width="30%" class="contentsml" valign="top" align="right"><%=adoRs5("busprice")%>&nbsp;
    </td>
       </tr>
    <%	        
                    adoRS5.Movenext        
                    LOOP	
                    adoRs5.Close 
                    set adoRs5 = nothing 
                    GalConn4.Close 
                    set Galconn4 = nothing
                    End if
      %> 
    
        <tr>
              <td HEIGHT="2" colspan="2"><SPACER TYPE="block" WIDTH="1" HEIGHT="2"></td>
               </tr>
       <tr>
              <td HEIGHT="1" colspan="2" bgcolor="#000000"><SPACER TYPE="block" WIDTH="1" HEIGHT="1"></td>
               </tr> 
                <tr>
              <td HEIGHT="2" colspan="2"><SPACER TYPE="block" WIDTH="1" HEIGHT="2"></td>
               </tr>                          <%	
                       
                    adoRS4.Movenext        
                    LOOP	
                    adoRs4.Close 
                    set adoRs4 = nothing 
                   
                    GalConn3.Close 
                    set Galconn3 = nothing
                    
                    End if
    %>
    
    Code (markup):
     
    barnet, Feb 5, 2009 IP
  2. kellywriter

    kellywriter Banned

    Messages:
    81
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You should post your table structure too , i think you are using select dist * so it would look for complete unique records in all the fields.
     
    kellywriter, Feb 8, 2009 IP
  3. gnp

    gnp Peon

    Messages:
    137
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Beware that you code is vulnerable to SQL injection attacks...
     
    gnp, Feb 14, 2009 IP
  4. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #4
    website looks great, but read up on SQL injection: http://www.unixwiz.net/techtips/sql-injection.html
    as for your original problem, i can't see it. massage is repeated but for different session times. all seperate database entries by the looks of it.
     
    camjohnson95, Feb 16, 2009 IP
  5. alexpr07

    alexpr07 Active Member

    Messages:
    284
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    73
    #5
    I don't see this problem also. Did you fix it?
     
    alexpr07, Feb 26, 2009 IP