×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Data in DB table cell not displaying in asp page table cell

Data in DB table cell not displaying in asp page table cell

Data in DB table cell not displaying in asp page table cell

(OP)
Hi Tech!

Thanks in advance for your help. Tek-Tips has always been extremely helpful when I'm expreriencing stumpage.

I have an asp page that connects to a database. Everything works great except for this one table cell on the page.

In the database is a table, tblTravelHistory:



(there are other records in the table, but that's not relevant.)

Here is the output to the table on the asp page:



As you can see, the Notes cell is empty, where the database table shows "initial entry" in the field mfldNotes. This is the problem.

Here is the relevant code for the page:

CODE

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>

   <head>

      <style type="text/css">

	 table.better {
            border-collapse: collapse;
            padding: 2px;
            }

	 table.better, th.better {
            border-style: solid;
            border-width: 1px;
            border-color: #002B53;
            }

	 tr.better:hover {background-color: #ccddff;}

	 th.better {
            background-color: #2B5BA2;
            font-family: arial;
            font-size: small;
            color: white;
            padding: 4px;
            }

	 td.better {
            border-style: solid;
            border-width: 1px;
            border-color: #002B53;
            font-family: arial;
            font-size: small;
            font-weight: bold;
	    text-align: left;
            padding: 4px;
            }

	 td.better0a {
            border-style: solid;
            border-width: 1px;
            border-color: #002B53;
            font-family: arial;
            font-size: small;
            font-weight: bold;
	    text-align: center;
	    color: #009900;
            padding: 4px;
            }

	 td.better0b {
            border-style: solid;
            border-width: 1px;
            border-color: #002B53;
            font-family: arial;
            font-size: small;
            font-weight: bold;
	    text-align: center;
	    color: #FF0000;
            padding: 4px;
            }

      </style>

<%

   Dim conn			
   Dim rs
   Dim strSQL
   Dim strConnection
   Dim idxItems
   Dim i
   Dim InOut
   Dim temp

   Set conn = Server.CreateObject("ADODB.Connection")
   Set rs = Server.CreateObject("ADODB.Recordset")

   idxItems = rs("idxItems")

   InOut = array("IN", "OUT")

   Response.Write("<title>" & Session("name") & " Collection</title></head><body style='margin-left: 20px;'>")

   conn.Open strConnection

   strSQL = "SELECT ynfldInOut, dfldDate, mfldNotes, tfldReference FROM tblTravelHistory " & "WHERE nfldidxItems=" & idxItems & ";"

   Set rs = conn.Execute (strSQL)

   Response.Write("<table class='better'><caption style='font-family: arial; font-size: small; font-weight: bold; text-decoration: underline;'>Travel History</caption>" & _
      "<tr><th class='better'>IN / OUT</th><th class='better'>Date</th><th class='better'>Notes</th><th class='better'>Reference</th></tr>")

   rs.MoveFirst

   Do While Not rs.EOF
      Response.Write ("<tr class='better'>")

      For i = 0 to rs.Fields.Count - 1

      temp = rs.Fields(i)

      If i = 0 Then
         If temp + 1 = 0 Then 
            temp = "0a'>" & InOut(temp + 1)
         Else
            If temp + 1 = 1 Then 
               temp = "0b'>" & InOut(temp + 1)
            End If
         End If
      Else
         temp = "'>" & rs.Fields(i)
      End If

      Response.Write("<td class='better" & temp & "</td>")
      Next

      Response.write("</tr>")

      rs.MoveNext
   Loop

   Response.Write("</table>")
	
   rs.Close

   Response.Write("</body></html>")

   set rs = Nothing
   conn.Close
   set conn = Nothing
   Response.End
%> 

(there's more to the page, but as it all works great I haven't included it.)

I can't figure it out, especially as I have five other tables on the page that display perfectly with basically the same code, EXCEPT that four of them don't use the InOut array. Why would this one cowardly field and/or table cell stubbornly refuse to show itself?

I humbly turn the problem over to you Tek-Tippers, who have proven yourselves in the past to be much smarter than I.

RE: Data in DB table cell not displaying in asp page table cell

I don't see any errors yet in the code that creates the HTML table that would cause "notes" to not show.

But I do see one odd thing in the code below:

CODE

Set rs = Server.CreateObject("ADODB.Recordset")
idxItems = rs("idxItems")

InOut = array("IN", "OUT")
Response.Write("<title>" & Session("name") & " Collection</title></head><body style='margin-left: 20px;'>")
conn.Open strConnection

strSQL = "SELECT ynfldInOut, dfldDate, mfldNotes, tfldReference FROM tblTravelHistory " & "WHERE nfldidxItems=" & idxItems & ";"
Set rs = conn.Execute (strSQL) 

The first line defines a recordset, but before you have even opened it, in the second line you are assigning idxItems to a value from it (rs("idxItems")), which is a value of a recordset that is not even open??? Yet you use this value a few lines down to actually open the recordset. I would expect an error to have been generated at some point, so I'm surprised the code even gets past this point.

RE: Data in DB table cell not displaying in asp page table cell

(OP)
Oops! Well spotted, guitarzan.

That was just an error from my clumsy copy and pasting. The variable idxItems holds a value from a previously opened recordset that filters the results of the SQL statement. As I didn't paste the code for the entire page (it's too onerous), I just pasted that line in the wrong place.

I really appreciate you looking at my problem.

RE: Data in DB table cell not displaying in asp page table cell

Then I dont see a problem. Maybe add this at the end of your loop

CODE

Next
Response.write("</tr>")
s = s & "Note: " & rs("mfldNotes") & "<br>"
rs.MoveNext 

and then add "response.write s" at the end, so see if any of the records have values in the Notes field. If so, maybe its a css format issue

RE: Data in DB table cell not displaying in asp page table cell

If you load the page and then view source to get the HTML output that might give you some clues. Are you able to paste the HTML output here?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close