Search Tools Links Login

How to dynamically create a HTML table from an ADO recordset !.


Shows how to dynamically create a HTML table from a recordset. All you need is the connection string and the table name.

Original Author: iNet1

Code

<br/>**********************************************************************<br/> How to dynamically create a html table from an ADO recordset !.<br/> <br/> All you need is your connection string and Table name, and<br/> off you go !.<br/>**********************************************************************<br/><% <br/> Dim conn<br/> Dim cmd<br/> Dim rs<br/> <br/> Set conn = Server.CreateObject("ADODB.Connection")<br/> Set cmd = Server.CreateObject("ADODB.Command")<br/> <br/> cmd.ActiveConnection = "Provider = MSDASQL;Data Source=Northwind;Database=Northwind;User Id=;Password=;"&nbsp;&nbsp;<br/> cmd.CommandText = "SELECT * FROM Customers"<br/> <br/> Set rs = cmd.Execute<br/> <br/> Response.Write "<table width=100% border=1>" <br/> Response.Write "<tr>" <br/> for i = 1 to rs.Fields.Count - 1<br/> Response.Write "<td><strong>" & rs.Fields(i).Name & "<strong></td>" <br/> next<br/> Response.Write "</tr>"<br/> <br/> Do While Not rs.EOF<br/> Response.Write "<tr>" <br/> for i = 1 to rs.Fields.Count - 1<br/> Response.Write "<td>" & rs.Fields(i) & "</td>" <br/> next<br/> rs.MoveNext<br/> Response.Write "</tr>"<br/> Loop<br/> Response.Write "</table>"<br/>%><br/>

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 129 times

Categories

ASP/ HTML

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.