Retrieve ADO Recordset Field names (Classic ASP)

感情迁移 提交于 2019-11-30 19:57:49

Given an ado record set you could do roughly the following (This is in psuedo code):

foreach (field in rs.Fields)
{
    alert(field.Name);
}

This will give you the name of the field check out this documentation.

Something like this ought to do it:-

 <table>
   <thead>
      <tr>
         <%For Each fld in rst.Fields%>
           <th><span><%=Server.HTMLEncode(fld.Name)%></span></th>
         <%Next %>
      </tr>
   </thead>
   <tbody>
 <%
   Do Until rst.EOF
      OutputRow rst.Fields
      rst.MoveNext
   Loop
 %>
   </tbody>
 </table>

 Sub OutputRow(fields)
 %>
      <tr>
         <%For Each fld in fields%>
           <td><span><%=Server.HTMLEncode(fld.Name)%></span></td>
         <%Next %>
      </tr>
 <%
 End Sub
 %>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!