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! |
As businesses grow increasingly dependent upon Web applications to provide services to customers, employees and partners, these complex applications become more difficult to secure. Although traditional security solutions protect Internet infrastructure layers, they do not guard against HTTP and HTML attacks. Many organizations that conduct security testing still deploy applications that allow attackers to manipulate their logic and wreak havoc on their business. To mitigate this risk, development and delivery teams must address Web application security throughout the lifecycle, addressing the many layers detailed in this paper. FREE! Go There Now!
|
|
|
|
Visit IBM developerWorks to download a free trial version of Lotus Quickr 8.0, which enables collaboration by transforming the way everyday business content such as documents, rich media, photos, and video can be shared. Lotus Quickr makes it faster and easier to share content of all types (not just documents) within virtual teams. It is designed to make it easier to collaborate across organizational boundaries, while continuing to work within the context of familiar desktop applications. FREE! Go There Now!
|
|
|
|
Visit IBM developerWorks to download IBM DB2 Express-C 9.5, a no-charge version of DB2 Express 9 database server. DB2 Express-C offers the same core data server base features as other DB2 Express editions and provides a solid base to build and deploy applications developed using C/C++, Java, .NET, PHP, and other programming languages. FREE! Go There Now!
|
|
|
|
Visit IBM developerWorks to download a free trial of the latest release of IBM Lotus Sametime Standard V8.0. Lotus Sametime Standard V8.0 is a platform for unified communications and collaboration that combines security features with an extensible, open solution including integrated Voice over IP, geographic location awareness, mobile clients, and a robust Business Partner community offering telephony and video integration. FREE! Go There Now!
|
|
|
|
Analysts, architects, and developers who have existing COBOL or PL/I skills and want to extend those skills to deploy new workloads on the mainframe can use the IBM Enterprise Modernization Sandbox for System z to find hands-on walkthroughs of common real world scenarios. The scenarios provide examples of how to rapidly design, create, assemble, test, and deploy high-quality Web, Web services, portal, and SOA applications for IBM CICS, IBM IMS, and IBM WebSphere Application Server. FREE! Go There Now!
|
|
|
|
Learn from the best! Find out how developers use Rational ClearCase to be more flexible, innovative and deliver higher quality code in the Rational ClearCase Power Users eKit. This complimentary eKit provides a collection of materials, like articles, whitepapers, and demos that can help you become a power user of Rational ClearCase. FREE! Go There Now!
|
|
|
|
Regression testing -- in which code is thoroughly tested to ensure that changes have not produced unexpected results -- is an important part of any development process. But many testing environments neglect the terminal-based applications that still form the backbone of many industries. In this tutorial, you'll learn how the Rational Functional Tester Extension for Terminal-Based Applications works with other Rational Functional Tester to help test terminal-based applications quickly and easily. 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!
|
|
|
|
Attend this launch webcast with Scott Hebner, Vice President of IBM Rational Marketing and Strategy, where he will overview Rational’s new offerings and programs to help customers accelerate software innovation on System z. He will discuss how these solutions help organizations extend their core business processes toward modern architectures such as SOA and web technologies to deliver business improvements that stand the test of time. FREE! Go There Now!
|
|
|
|
All FREE IBM® developerWorks Tools! |