Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2003
    Posts
    5

    Unanswered: Formatting database results.

    I am trying to setup my database listing so that the data is sorted in multiple colums side by side. Here's the code:
    Code:
    <TABLE Border=1 CellPadding=3 bgColor=23415D>
    <%
    SQL = "SELECT * FROM tblCategory, tblBusiness " _
    	  & " WHERE tblBusiness.CategoryID = tblCategory.ID " _
    	  & " AND tblCategory.ID IN (" & catsChosen & ")" _
    	  & " ORDER BY CategoryName, Name"
    
    Set RS = catConn.Execute(SQL)
    
    priorCat = ""
    
    Do Until RS.EOF
    	curCat = RS("CategoryName")
    	If curCat <> priorCat Then
    	Response.Write "<TR >" _
    	& "<TD colspan=2 align=center>" & "<font size=4 color=FFFFFF>" & "<B>" & curCat & "</font>" & "</b>" & "</TD>" _
    	& "</TR>" & vbNewLine
    	priorCat = curCat
    	End If
    	Response.Write "<TR><TD>" _
    	& "<B>" & RS("Name") & "</b>" & "<br>" & RS("Address") & "<br>" & RS("City") & ", " & RS("State") & " " & RS("Zip") & "<br>" & RS("Phone") & "</TD>" & vbNewLine
    	RS.MoveNext
    	Response.Write "<TD>" & "<B>" & RS("Name") & "</b>" & "<br>" & RS("Address") & "<br>" & RS("City") & ", " & RS("State") & " " & RS("Zip") & "<br>" & RS("Phone") & "</TD>" _
    	& "</TR>" & vbNewLine
    	Rs.MoveNext
    Loop
    Response.Write "</TABLE>" & vbNewLine
    RS.Close
    
    ' end of displaying results from prior request...if any
    '
    End If
    %>
    The problem I am having is down at the bottom. I create one side of the table, then I want to move to the next record to create the other side. I keep getting an error 80020009 with no other information, just
    index2.asp, line 63. I really am just a newb so any help you can give would be appreciated.

    I have the page posted at http://www.tcurtis45.dns2go.com/index2.asp

    Thank you,

    Tony
    Last edited by tcurtis45; 07-01-03 at 21:21.

  2. #2
    Join Date
    Jun 2003
    Posts
    5

    Update info

    I didn't mention, the line that is erroring out is line 62 which is:

    Response.Write "<TD>" & "<B>" & RS("Name") & "</b>" & "<br>" & RS("Address") & "<br>" & RS("City") & ", " & RS("State") & " " & RS("Zip") & "<br>" & RS("Phone") & "</TD>" _

  3. #3
    Join Date
    Jun 2003
    Posts
    5

    SupaNewb

    Ok after more dileberation and finding a great article about formatting tables on your asp page at
    http://www.4guysfromrolla.com/webtech/102299-1.shtml

    I finally got it to work and it was not nearly as difficult as I might have thought. I will post the code that worked for me so others might be able to answer their questions.

    Code:
    <%
    SQL = "SELECT * FROM tblCategory, tblBusiness " _
    	  & " WHERE tblBusiness.CategoryID = tblCategory.ID " _
    	  & " AND tblCategory.ID IN (" & catsChosen & ")" _
    	  & " ORDER BY CategoryName, Name"
    
    Set RS = catConn.Execute(SQL)
    
    priorCat = ""
    
      i = 1
      do until RS.eof
    	curCat = RS("CategoryName")
    	If curCat <> priorCat Then
    	  Response.Write "<TR >" _
    	& "<TD colspan=2 align=center>" & "<font size=4 color=FFFFFF>" & "<B>" & curCat & "</font>" & "</b>" & "</TD>" _
    	& "</TR>" & vbNewLine
    	priorCat = curCat
    	End If    
    	cellString = "<TD>" & "<B>" & RS("Name") & "</b>" & "<br>" & RS("Address") & "<br>" & RS("City") _
    	& ", " & RS("State") & " " & RS("Zip") & "<br>" & RS("Phone") & "</TD>"
    
        if not i mod 2 = 0 then
          response.write(cellString)
        else
          response.write(cellString) & "</tr><tr>" & vbNewLine
        end if		
    
        i = i + 1
        RS.movenext
      loop
    Response.Write "<TR>" & "</TABLE>" & vbNewLine
    RS.Close
    
    ' end of displaying results from prior request...if any
    '
    End If
    %>
    Thanks anyway, I'm sure you will be seeing me again.

Posting Permissions

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