Posted By

ginoplusio on 11/19/08


Tagged

sql table tsql ASP


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

sulfurito
benrudolph


ASP show a sql table


 / Published in: ASP
 

URL: http://www.barattalo.it/

show a table with data and his column name

  1. <%
  2. Set Conn = Server.CreateObject("ADODB.Connection")
  3. Set rst = Server.CreateObject("ADODB.Recordset")
  4. Conn.Open Application("ConnectionString")
  5. Dim temp
  6. Dim i
  7. temp =0
  8. response.write "<table>"
  9. do while not rst.eof
  10. For i = 0 To rst.fields.count - 1
  11. If temp = 0 Then
  12. If i = 0 then response.write "<tr><td></td>"
  13. response.write "<th>" & rst(i).name & "</th>"
  14. If i = rst.fields.count - 1 then response.write "</tr>"
  15. End If
  16. Next
  17. For i = 0 To rst.fields.count - 1
  18. If i = 0 then response.write "<tr><td>" & temp & "</td>"
  19. response.write "<td>" & rst(i)
  20. response.write("</td>")
  21. If i = rst.fields.count - 1 then response.write "</tr>"
  22. Next
  23. temp = temp + 1
  24. rst.movenext
  25. loop
  26. response.write "</table>"
  27. rst.close
  28. set rst=nothing
  29. %>

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: joeydi on February 20, 2009

If Not ReportRS.EOF Then Response.Write("") Response.Write("") For Each field in ReportRS.fields Response.Write("" & field.name & "") Next Response.Write("") Do While Not ReportRS.EOF Response.Write("") For Each field in ReportRS.fields Response.Write("" & ReportRS(field.name) & "") Next Response.Write("") ReportRS.MoveNext Loop Response.Write("") End If

Posted By: ginoplusio on January 19, 2010

what?

You need to login to post a comment.