By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,835 Members | 1,909 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,835 IT Pros & Developers. It's quick & easy.

ASP & html tables : have strange problem

P: n/a
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.

Jul 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
HenryW wrote on 21 mrt 2004 in microsoft.public.inetserver.asp.general:
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


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)
Jul 19 '05 #2

P: n/a
HenryW wrote:
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.


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:

http://www.aspfaq.com/show.asp?id=2467

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"
Jul 19 '05 #3

P: n/a
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
HenryW wrote on 21 mrt 2004 in microsoft.public.inetserver.asp.general:
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


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>

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


Jul 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.