ASP & html tables : have strange problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • HenryW

    ASP & html tables : have strange problem

    I have a section of ASP code that dynamically builds a table. And per
    usual it writes out to the table like so:

    Response.Write( "<td><font face=""Verdana" " size=""2""><b> Status
    </b></font></td>")
    Response.Write( "<td><font face=""Verdana" " size=""2""><b> Description
    </b></font></td>")

    ' make a couple of column headers

    Do While Not objRS.EOF

    Response.Write( "<td><font face=""Verdana" " size=""2"">" &
    objRS("chg_stat ") & "</font>" & "</td>")
    Response.Write( "<td><font face=""Verdana" " size=""2"">" &
    bjRS("co_desc") & "</font>" & "</td></tr>")

    ObjRS.MoveNext

    Loop

    Response.Write "</table>"
    'Clean up
    'Response.Write "The Sql just executed was:: " &
    "<br>" & strSql& "<br>" ' see the sql and check it in enterprise mngr

    objRS.Close
    Set objRS = Nothing
    ObjConn.Close
    Set objConn = Nothing


    NOW THE PART THAT DRIVES ME CRAZY.

    The actual code invloves alot more columns/rows and the recordset is
    good size.
    The problem is this:

    Once I get 6 columns, no matter how I adjust the width, etc, I start
    losing my data... a line that looks like this:

    Response.Write( "<td><font face=""Verdana" " size=""2"">" &
    objRS("chg_stat ") & "</font>" & "</td>")

    and has data in the recordset element will (after column #6) result in

    <td></td>

    in the resluting html... I worked on this for 4 hours Friday. To
    sanity check myself, I got 1 line of code working and then copied and
    pasted so there are zero typos.

    And again after 6 columns, the <td></td> started again with no data,
    and you may rest assured my recordset object had data in those
    variables at runtime....I know I checked.
    I felt like I was losing my mind.
    I'm also sort of new to ASP.
    Any ideas at all?

    TIA, most humbly.

  • Evertjan.

    #2
    Re: ASP &amp; html tables : have strange problem

    HenryW wrote on 21 mrt 2004 in microsoft.publi c.inetserver.as p.general:
    [color=blue]
    > Do While Not objRS.EOF
    >
    > Response.Write( "<td><font face=""Verdana" " size=""2"">" &
    > objRS("chg_stat ") & "</font>" & "</td>")
    > Response.Write( "<td><font face=""Verdana" " size=""2"">" &
    > bjRS("co_desc") & "</font>" & "</td></tr>")
    >
    > ObjRS.MoveNext
    >
    > Loop
    >[/color]

    Where is the <tr> ???
    the second objRS( misses an o

    =============== ===========

    [two " & " are superfluous, btw]
    [use single quotes clientside, I advise]
    ["until" is the same as "while not"]
    [do not use () after response.write-s]

    To make the whole thing even more visually overseeable and debuggable,
    make seperate <tr></tr>-s, <td>..</td>-s, use css, and indenting:

    =============== ===========

    <style>
    .mytable tr td {font-family:verdana; font-size:1.1em}
    </style>"
    ......
    <table class='myTable' >
    <%
    Do Until objRS.EOF
    Response.Write "<tr>"
    Response.Write "<td>" & objRS("chg_stat ") & "</td>"
    Response.Write "<td>" & objRS("co_desc" ) & "</td>"
    Response.Write "</tr>"
    ObjRS.MoveNext
    Loop
    %>
    </table>

    =============== ===========

    or even [my personal preference]:

    =============== ===========

    <style>
    .mytable tr td {font-family:verdana; font-size:1.1em}
    </style>"
    ......
    <table class='myTable' >

    <%
    Do Until objRS.EOF
    %>
    <tr>
    <td><% = objRS("chg_stat ") %></td>
    <td><% = objRS("co_desc" ) %></td>
    </tr>
    <%
    ObjRS.MoveNext
    Loop
    %>

    </table>

    =============== ===========




    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)

    Comment

    • Bob Barrows

      #3
      Re: ASP &amp; html tables : have strange problem

      HenryW wrote:[color=blue]
      > I have a section of ASP code that dynamically builds a table. And per
      > usual it writes out to the table like so:
      >
      > Response.Write( "<td><font face=""Verdana" " size=""2""><b> Status
      > </b></font></td>")
      > Response.Write( "<td><font face=""Verdana" " size=""2""><b> Description
      > </b></font></td>")
      >
      > ' make a couple of column headers
      >
      > Do While Not objRS.EOF
      >
      > Response.Write( "<td><font face=""Verdana" " size=""2"">" &
      > objRS("chg_stat ") & "</font>" & "</td>")
      > Response.Write( "<td><font face=""Verdana" " size=""2"">" &
      > bjRS("co_desc") & "</font>" & "</td></tr>")
      >
      > ObjRS.MoveNext
      >
      > Loop
      >
      > Response.Write "</table>"
      > 'Clean up
      > 'Response.Write "The Sql just executed was:: " &
      > "<br>" & strSql& "<br>" ' see the sql and check it in enterprise mngr
      >
      > objRS.Close
      > Set objRS = Nothing
      > ObjConn.Close
      > Set objConn = Nothing
      >
      >
      > NOW THE PART THAT DRIVES ME CRAZY.
      >
      > The actual code invloves alot more columns/rows and the recordset is
      > good size.
      > The problem is this:
      >
      > Once I get 6 columns, no matter how I adjust the width, etc, I start
      > losing my data... a line that looks like this:
      >
      > Response.Write( "<td><font face=""Verdana" " size=""2"">" &
      > objRS("chg_stat ") & "</font>" & "</td>")
      >
      > and has data in the recordset element will (after column #6) result in
      >
      > <td></td>
      >
      > in the resluting html... I worked on this for 4 hours Friday. To
      > sanity check myself, I got 1 line of code working and then copied and
      > pasted so there are zero typos.
      >
      > And again after 6 columns, the <td></td> started again with no data,
      > and you may rest assured my recordset object had data in those
      > variables at runtime....I know I checked.
      > I felt like I was losing my mind.
      > I'm also sort of new to ASP.
      > Any ideas at all?
      >
      > TIA, most humbly.[/color]

      Firstly, do this to verify that your recordset contains all the data you
      think it does:

      response.write objRS.getString (,," | ", "<BR>")


      Given that you seem to have checked your sql in Query Analyzer (you should
      be using a stored procedure, not dynamic sql, but that's a topic for another
      post - if you're interested, use Google to search for posts by me on this
      topic), I suspect that it does contain your data, but it does not hurt to
      verify it.

      I suggest you use a GetRows array to populate your table instead of a
      recordset loop. see this article for details:





      If this does not help, we will need to see more of your looping code. what
      you've shown above should work, so there has to be something we're not
      seeing. The code to produce the header is totally irrelevant. All we need to
      see is the section where you are looping through the fields in the recordset
      (if you choose to persist in the klunky recordset loop instead of using the
      more efficient array loop, that is)

      Bob Barrows
      --
      Microsoft MVP - ASP/ASP.NET
      Please reply to the newsgroup. This email account is my spam trap so I
      don't check it very often. If you must reply off-line, then remove the
      "NO SPAM"


      Comment

      • HenryW

        #4
        Re: ASP &amp; html tables : have strange problem

        Evertjan

        Thats real clean nice code, thanks I think it will help.

        Bob thanks to you as well, I will look into the array thing, like I
        said I'm new to ASP

        Henry
        [color=blue]
        >HenryW wrote on 21 mrt 2004 in microsoft.publi c.inetserver.as p.general:
        >[color=green]
        >> Do While Not objRS.EOF
        >>
        >> Response.Write( "<td><font face=""Verdana" " size=""2"">" &
        >> objRS("chg_stat ") & "</font>" & "</td>")
        >> Response.Write( "<td><font face=""Verdana" " size=""2"">" &
        >> bjRS("co_desc") & "</font>" & "</td></tr>")
        >>
        >> ObjRS.MoveNext
        >>
        >> Loop
        >>[/color]
        >
        >Where is the <tr> ???
        >the second objRS( misses an o
        >
        >============== ============
        >
        >[two " & " are superfluous, btw]
        >[use single quotes clientside, I advise]
        >["until" is the same as "while not"]
        >[do not use () after response.write-s]
        >
        >To make the whole thing even more visually overseeable and debuggable,
        >make seperate <tr></tr>-s, <td>..</td>-s, use css, and indenting:
        >
        >============== ============
        >
        ><style>
        > .mytable tr td {font-family:verdana; font-size:1.1em}
        ></style>"
        >.....
        ><table class='myTable' >
        ><%
        >Do Until objRS.EOF
        > Response.Write "<tr>"
        > Response.Write "<td>" & objRS("chg_stat ") & "</td>"
        > Response.Write "<td>" & objRS("co_desc" ) & "</td>"
        > Response.Write "</tr>"
        > ObjRS.MoveNext
        >Loop
        >%>
        ></table>
        >
        >============== ============
        >
        >or even [my personal preference]:
        >
        >============== ============
        >
        ><style>
        > .mytable tr td {font-family:verdana; font-size:1.1em}
        ></style>"
        >.....
        ><table class='myTable' >
        >
        ><%
        >Do Until objRS.EOF
        >%>
        > <tr>
        > <td><% = objRS("chg_stat ") %></td>
        > <td><% = objRS("co_desc" ) %></td>
        > </tr>
        ><%
        > ObjRS.MoveNext
        >Loop
        >%>
        >
        ></table>
        >
        >============== ============[/color]

        Comment

        Working...