Srikant Boddepalli
Srikant Boddepalli

Reputation: 11

Rows as columns classic ASP

I have a table with below columns.

app_role, app_desc and user_id

We want to print the data in in below format - instead of data being printed in Rows, it has to be printed in columns. For each row in database, it should be printed in a column

app_role | app_role | app_role

app_desc | app_desc | app_desc

user_id  |  user_id | user_id

I need to achieve this in classic ASP

I will be using a record set to retrieve the data

kindly advise.

Upvotes: 0

Views: 1422

Answers (1)

pee2pee
pee2pee

Reputation: 3792

Presuming you have a recordset of RS, a very simple version would be

<% if not rs.eof then %>
  <table>
  <tr>
  <%while not rs.eof%>
      <td><%=app_role%>
      <br/><%=app_desc%>
      <br/><%=user_id%></td>
  <%rs.movenext
  wend %>
  </tr>
  </table>
<%end if%>

Or something like that but without more information, I can't be 100% sure. If you want one in a new cell then maybe this might work http://www.w3schools.com/ado/met_rs_getrows.asp

Basically put the recordset in an array and access each element itself.

As Lankymart suggested, doing it in SQL might be easier. An example can be found here http://sqlfiddle.com/#!3/1b1b7/1 presuming you have the correct version of SQL server

Upvotes: 1

Related Questions