This is a demo shows how to take a Recordset and write out the data using the NAME property and all data associated with that Name. This was something I ran across and found very useful. Its very nice when presenting data in HTML.
This is what the data looks like once its been selected and written out.
| id | EmailAddress | Homepage |
|---|
| 1 | johndoe@blah.com | http://www.someurl.com |
| 2 | blahman@blah.com | http://www.someurl.com |
| 3 | Aperson@blah.com | http://www.someurl.com |
| 4 | Jane@blah.com | http://www.somewhere.com |
| 5 | henry@blah.com | http://www.someURL.com |
Here is the code that created the table presented above
<%@ Language = "VBScript"%>
<%
response.buffer = true
On Error Resume Next
strconn = "Driver={SQL Server};Description=connstring;SERVER=127.0.0.1;UID=loginid;PWD=password;DATABASE=some_db"
dim conn
dim rs
dim strID
dim strSql
set conn = server.createobject("adodb.connection")
set rs = server.createobject("adodb.recordset")
conn.open strconn
strSql = "SELECT tblWriteOutHeader.id, tblWriteOutHeader.EmailAddress, tblWriteOutHeader.Homepage" & _
" FROM tblWriteOutHeader" & _
" ORDER BY tblWriteOutHeader.id"
rs.open strsql, conn
%>
<% rs.movefirst %>
<html><head>
<title>Write out headers</title></head><body>
<TABLE BORDER="1" width="80%"><TR> 'This section writes out the Names of the fields in the Recordset<% For Each Field In RS.Fields %>
<TH> <% If Field.Name <> "ID" Then
response.write Field.name
End If %>
</TH>
<% Next %> </TR>
'This section writes out the DATA of the fields in the Recordset<% Do While Not RS.EOF %> <TR> <% For Each Field In RS.Fields %> <TD ALIGN=center> <%If IsNull(Field) Then Response.Write ""
Else
Response.Write Field.Value
End If %>
</TD><% Next RS.MoveNext %>
</TR> <% Loop %> </TABLE> <%
Rs.Close
Set Rs = Nothing
%>
<p> </p>
</body>
</html>
<%
conn.close
set conn = nothing
%>
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |
More ASP Code Articles
More By aspfree
developerWorks - FREE Tools! |
This demonstration gives you an overview of IBM® Rational® Build Forge Express Edition, a global offering that provides a framework to automate and execute software processes. Rational Build Forge provides a software assembly line that can support all of your tools, technologies, and platforms so you can achieve a repeatable, reliable, and traceable build and release process. FREE! Go There Now!
|
|
|
|
The IBM DB2 Deep Compression ROI tool is designed for DBA’s and IT management personnel to perform a clinical analysis of the cost savings gained from the Storage Optimization feature of DB2 9 for Linux, UNIX and Windows. The feature, also known as Deep Compression, compresses data that lies within a database by up to 80% at times. FREE! Go There Now!
|
|
|
|
Learn field-tested SOA principles, methodology, technology and implementation from the global SOA market leader - in a new e-book by an IBM SOA expert. Written by IBM Certified SOA Solution Designer Bobby Woolf, "Exploring IBM SOA Technology & Practice" is the ultimate insider's guide to SOA - a PDF e-book packed cover to cover with IBM's specific advice on how to make your SOA implementation a success. FREE! Go There Now!
|
|
|
|
Achieving true agility is a never-ending effort. We will showcase how you can become agile incrementally, a few practices at the time.Which practices should any agile team strive to adopt? What additional practices should you consider based on your needs to scale? Adopting practices are however made much easier with the right tool support. What about if your tools adapt to your practices? We will take a look at how the Jazz technology can be leveraged to make your process change the behavior of your tools. FREE! Go There Now!
|
|
|
|
Download a free trial version of IBM Rational Developer for System i V7.1, which provides a complete development environment for traditional i5/OS application development. IBM Rational Developer for System i is a new eclipse-based workstation offering for i5/OS application development that provides a comprehensive Integrated Development Environment for edit/compile/debug of traditional RPG/COBOL/C/C++ i5/OS applications. FREE! Go There Now!
|
|
|
|
Learn how Rational Build Forge can extend a simple compile and package build process by adding customization and deployment capability. Go from a manual method to automating: checking for code changes; getting the latest source; compiling and packaging; customizing; copying to and restarting a deployment server; and sending e-mail notification that a new version is available. FREE! Go There Now!
|
|
|
|
Listen to this webcast to get an overview of Info 2.0 and a technical demo of how to quickly build an enterprise mashup. IBM's Info 2.0 technology leverages emerging Web 2.0 technologies such as mashups, feeds, AJAX, and JSON in order to simplify assembly of information using feeds and services. Come learn about the technical elements of Info 2.0 including the Feed Generation framework, Mashup Engine, and mashup assembly components. Learn how to pull information from databases, departmental information, and the Web to create mashups critical to your company’s success. We will also discuss best practices to help you get started. FREE! Go There Now!
|
|
|
|
Get a free trial download of the latest version of IBM Rational Tester for SOA Quality V7.0.1, a functional and regression testing tool that enables the creation, comprehension, modification and execution of testing GUI-less Web services. FREE! Go There Now!
|
|
|
|
Visit IBM developerWorks to try the IBM SOA Sandbox for people. The SOA Sandbox for people provides a trial environment with the necessary tooling and components required to enable consistent human and process interaction and collaboration, showing how you can improve user experience and business productivity. FREE! Go There Now!
|
|
|
|
Join this Rational Talks to You teleconference, to hear how Enterprise Generation Language (EGL) eliminates the need for tedious and error-prone low level coding, so developers can focus on business requirements. EGL extends the Rational software development platform with a simplified programming language that enables developers who have little or no experience with Java, Web technologies or Service Oriented Architecture, to create enterprise-class applications and services quickly and easily. It also allows developers who may have little or no mainframe programming experience to quickly create traditional mainframe components. FREE! Go There Now!
|
|
|
|
All FREE IBM® developerWorks Tools! |