Home arrow ColdFusion arrow Page 4 - Querying SQL 2000 Server from ColdFusion
COLDFUSION

Querying SQL 2000 Server from ColdFusion


Following a brief explanation about the database drivers and the application environment in which the ColdFusion MX Server is installed, this tutorial describes a step-by-step method of creating a ColdFusion data source from the administrative panel of a ColdFusion MX 6.1 Server which derives its data from a MS SQL 2000 server. The tutorial then describes a ColdFusion application for running a database query against this data source.

Author Info:
By: Jayaram Krishnaswamy
Rating: 5 stars5 stars5 stars5 stars5 stars / 4
February 07, 2006
TABLE OF CONTENTS:
  1. · Querying SQL 2000 Server from ColdFusion
  2. · Using ColdFusion data sources to connect to SQL Server 2000
  3. · Querying pubs database with a ColdFusion query
  4. · Modifying the query and improving the display

print this article
SEARCH DEVARTICLES

Querying SQL 2000 Server from ColdFusion - Modifying the query and improving the display
(Page 4 of 4 )

The query shown in the previous section returns 27 rows. In some cases this can be very large, and it is always a good practice to return only the required number of rows to improve performance and display. The next code improves upon the previous by limiting the rows to a maximum of 10, with the third row as the starting element. It also supplies the missing column for the row number as well as adding some style to the table. The correction and additions to the code are highlighted.

<!--select au_lname, au_fname, phone, city, zip from authors-->
<cfparam name="MaxRows" default="10">
<cfparam name="StartRow" default="3">
<cfquery name="GetAuthors" datasource="CFSQL">
select au_lname, au_fname, phone, city, zip from authors
order by au_lname
</cfquery>
<table border="1" bgcolor="lime">
<tr>
<!--Column headers-->
<!--add a column for row number-->
<td>Row Number</td>
<td>Last Name</td>
<td>First Name</td>
<td>Telephone</td>
<td>City</td>
<td>Zip Code</td>
</tr>
<!--output of query-->
<cfoutput query="GetAuthors" startrow="#StartRow#" maxrows="#MaxRows#">
<tr>
<td>#GetAuthors.CurrentRow#</td>
<td bgcolor="lightblue">#au_lname#</td>
<td bgcolor="lightblue">#au_fname#</td>
<td bgcolor="lightblue">#phone#</td>
<td bgcolor="lightblue">#city#</td>
<td bgcolor="lightblue">#zip#</td>
</tr>
</cfoutput>

When the above query is browsed you see the following displayed. The row starts with the third row and contains 10 rows as set by the <cfparam/> tags at the beginning of the code.

Summary

This tutorial is very basic and will help the beginners to start database programming with ColdFusion MX Server,  IIS and backend MS SQL Server 2000. The ColdFusion MX server's administration panel makes it painless to connect to a variety of databases, without worrying about the varied syntax of the connection string or the JDBC/ODBC interface information. The administrative panel also provides advanced features to set other operating parameters, as well as a one click button to verify the connectivity without writing a line of code.


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.

blog comments powered by Disqus
COLDFUSION ARTICLES

- Adobe ColdFusion Just Got More RAD
- How to Access a SQL Anywhere Database with C...
- CFXML: Probing XMLDOM in ColdFusion
- Creating a Web Service with ColdFusion: the ...
- CFAjax: What it is and How to Use it
- Querying SQL 2000 Server from ColdFusion
- Introduction to ColdFusion Markup Language, ...
- Introduction to ColdFusion Markup Language
- Databases and Dreamweaver MX 2004, concluded
- Databases and Dreamweaver MX 2004
- Welcome to Coldfusion MX 6.1, concluded
- Welcome to Coldfusion MX 6.1
- What You Must Know About ColdFusion Flow-Con...
- What You Must Know About Operators in ColdFu...
- Everything You Must Know About ColdFusion Va...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials