SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Jun 2001
    Location
    Malaysia
    Posts
    352
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    SQL Query String... getting field headers

    hey guys,

    I've got an ASP-SQL query as follows:

    <%
    <!--#include file="inc-dbconnection.asp"--> <% 'connect to a d/base
    Set objRS = objConn.Execute (SQLcode) %>

    <table cellpadding=5 border=1>
    <tr>
    <td><b>STD_ID</b></td>
    <td><b>STD_FNAME<b></td>
    <td><b>STD_MNAME</b></td>
    <td><b>STD_LNAME</b></td>
    <td><b>STD_FACULTY</b></td>
    <td><b>STD_COMMITMENT</b></td>

    </tr>

    <%Do While Not objRS.EOF%>
    <tr>
    <td><%=objRS("STD_ID")%></td>
    <td><%=objRS("STD_FNAME")%> </td>
    <td><%=objRS("STD_MNAME")%> </td>
    <td><%=objRS("STD_LNAME")%> </td>
    <td><%=objRS("STD_FACULTY")%> </td>
    <td><%=objRS("STD_COMMITMENT")%> </td>
    </tr>
    <% objRS.MoveNext
    Loop
    objRS.Close

    </table> %>

    The problem now is that I've got to manually type in the field headers into my table. Is there a way to have the query return the SELECTed statements, as well as all related field headers?
    Last edited by infinitium; Jan 17, 2002 at 04:12.

  2. #2
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,294
    Mentioned
    123 Post(s)
    Tagged
    1 Thread(s)
    This should get you what you want....

    Code:
    Response.Write "<tr>" & vbCrLf
    for i = 0 to (objRS.fields.count - 1)
    	Response.Write "	<td>" & rsColumns.fields(i).Name & "</td>" & vbCrLf 
    next
    Response.Write "</tr>"
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style
    Learn how to be ready for The Forums' Move to Discourse

  3. #3
    SitePoint Addict
    Join Date
    Jun 2001
    Location
    Malaysia
    Posts
    352
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks again Dave...

  4. #4
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,294
    Mentioned
    123 Post(s)
    Tagged
    1 Thread(s)
    Not a problem. Glad to share....
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style
    Learn how to be ready for The Forums' Move to Discourse


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •