Advertisement
3_2004-2005 String Manipulation #147306

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.

AI

KI-Zusammenfassung: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

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