ASP show a sql table


/ Published in: ASP
Save to your folder(s)

show a table with data and his column name


Copy this code and paste it in your HTML
  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. %>

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.