SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot Arkkimaagi's Avatar
    Join Date
    Mar 2002
    Location
    Lappeenranta, Finland
    Posts
    176
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How can I figure out SQL tables Column names with ASP?

    I'd like to know what column names an table has. I can see the data they contain, but not the column titles.

    I can use ASP to get this information from database.

  2. #2
    Rehab is for quiters! spartan's Avatar
    Join Date
    Apr 2002
    Location
    Cape Town, South Africa
    Posts
    343
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes you can...

    try this... (just error check, I'm writing on the fly here)
    Code:
    set rs = createobject("ADODB.recordset")
    rs.open "select * from mytable", conn
    
    'create a table to output column names and values
    '------------------------------------------------
    response.write "<TABLE><TR>"
    'write column names
    For each thingy in rs.fields
        response.write "<TD>" & thingy.name & "</TD>"
    next
    response.write "</TR>"
    
    'write contents
    while not rs.eof
        response.write "<TR>"
        For each thingy in rs.fields
           response.write "<TD>" & thingy & "</TD>"
        next
        response.write "</TR>"
        rs.movenext
    wend
    
    response.write "</TABLE>"
    Spartan
    ---------------------
    It's like our sergeant told us before one trip into the jungle. Men! Fifty of you are leaving on a mission. Twenty-five of you ain't coming back.
    -Mr.Payne

  3. #3
    Database Jedi MattR's Avatar
    Join Date
    Jan 2001
    Location
    buried in the database shell (Washington, DC)
    Posts
    1,107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What database are you using? You may be able to run a query to get the columns from a table at will.

  4. #4
    SitePoint Zealot Arkkimaagi's Avatar
    Join Date
    Mar 2002
    Location
    Lappeenranta, Finland
    Posts
    176
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you, I got it working


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
  •