locked
'Classic' asp data display question RRS feed

  • Question

  • User-1889146072 posted

    I have to do a project in 'classic' asp for a part of my company that still uses this language. Undecided  I need to display multiple fields from a .mdb file, and I can't envision how this is done. 

    My database is setup as:

    There are a series of categories with a list of titles in them, each with two results (salary and respondents). I need to display this in a table somehow. I've already created a page for this and plugged in some of the info, but I can't figure out how to display multiple fields. I'm not even sure if I built the database properly to do what I'm after: 

    <%
    
       Set myConnection = Server.CreateObject("ADODB.Connection")
       myConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _ Server.MapPath("/myDatabase.mdb")
       Set businessSectorSalary = myConnection.Execute("SELECT * FROM allTitles") 
    %>
    
    
    
    <table>
                  <thead>
                    <tr>
                      <th style="color:#ed1c24; width:70%;">BY BUSINESS SECTOR</th>
                      <th class="museoSans300" style="color:#ed1c24;">Salary</th>
                      <th class="museoSans300" style="color:#ed1c24;">Respondents</th>
                    </tr>
                  </thead>
                  <tbody>
                    <tr>
                      <td>Association</td>
                      <td><%Response.write(businessSectorSalary("salary1"))%></td>
                      <td align="center"><%Response.write(businessSectorSalary("respondents1"))%></td>
                    </tr>
    
    etc...

    This produces errors, but I don't have a clear view how to do this for multiple fields. 

    Thursday, November 3, 2016 9:49 PM

All replies

  • User-460007017 posted

    Hi jNew,

    This link provide a sample code to display column from database with classic asp:

    https://razorsql.com/articles/sqlserver_asp_column_names_values.html

    Best Regards,

    Yuk Ding

    Friday, November 4, 2016 8:58 AM
  • User-1889146072 posted

    I'm using Microsoft Access, not SQL. 

    Tuesday, November 15, 2016 9:09 PM
  • User-980872515 posted

    <div class="WordSection1">

    <% Set myConnection = Server.CreateObject("ADODB.Connection")   myConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _ Server.MapPath("/myDatabase.mdb")

       Set businessSectorSalary = myConnection.Execute("SELECT * FROM allTitles")

    %>

    Response.Write "<table><tr><th>BY BUSINESS SECTOR</th><th>Salary</th><th>Respondents</th></tr>"

    Do Until businessSectorSalary.EOF

        Response.Write "<tr>"

        Response.Write "<th>" &DataDisplay&"</th>"

        Response.Write "<td>" & DataDisplay & "</td>"

        Response.Write "<td>" & DataDisplay& "</td>"

        Response.Write "</tr>"

    businessSectorSalary.Movenext

    Loop

    Response.Write "</table>"

     </div>

    Saturday, November 19, 2016 5:17 AM