Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you print a Field Name to a table?

Status
Not open for further replies.

powahusr

Technical User
Jan 22, 2001
240
US
I’m currently learning ADO and do not know how to print field names to a table in an ASP document.

The following code prints the contents of the selected Table in a database but not the field names. I want the field names printed at the top of each respective column, how do you do it. Thanks in advance.

Here is the code:

<%
set conn=Server.CreateObject(&quot;ADODB.Connection&quot;)
conn.Provider=&quot;Microsoft.Jet.OLEDB.4.0&quot;
conn.Open &quot;c:\ASP\db4.mdb&quot;
set rs=Server.CreateObject(&quot;ADODB.recordset&quot;)
rs.Open &quot;Select * from uid&quot;, conn
%>

<table border=&quot;1&quot; width=&quot;100%&quot; bgcolor=&quot;#FFFFFF&quot; cellspacing=&quot;1&quot;>

<tr>
<%do until rs.EOF%>
<%for each x in rs.Fields%>
<td><%Response.Write(x.value)%>  </td>
<%next
rs.MoveNext%>
</tr>
<%loop
rs.close
conn.close
%>
 
Response.Write(x.value) is the value of the column
Response.Write(x.name) is the name of the column
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top