Exforsys

Online Training

how do i write a query in coldfusion?

This is a discussion on how do i write a query in coldfusion? within the Coldfusion forums, part of the Programming Talk category; how do i write a query in coldfusion?...


Go Back   Exforsys > Programming Talk > Coldfusion

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-19-2007, 12:10 PM
Junior Member
 
Join Date: Mar 2007
Posts: 1
gogbpackrs2 is on a distinguished road
how do i write a query in coldfusion?

how do i write a query in coldfusion?
__________________
Powered by Yahoo! Answers
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-24-2007, 08:29 AM
Senior Member
 
Join Date: Apr 2006
Posts: 153
cyrus is on a distinguished road
The following steps would help you to search and display the query results:
Create a Cold Fusion page with the following content:
<html>
<head>
<title>Searching a collection</title>
</head>
<body>

<h2>Searching a collection</h2>

<form method="post" action="collection_db_results.cfm">
<p>Collection name: <input type="text" name="collname" size="30"
maxLength="30"></p>

<p>Enter search term(s) in the box below. You can use AND, OR, NOT,
and parentheses. Surround an exact phrase with quotation marks.</p>
<p><input type="text" name="criteria" size="50" maxLength="50">
</p>
<p><input type="submit" value="Search"></p>
</form>

</body>
</html>

Save the file as collection_db_search_form.cfm in the myapps directory under the web_root.
This file is similar to collection_search_form.cfm, except the form uses collection_db_results.cfm, which you create in the next step, as its action page.

Create another Cold Fusion page with the following content:
<html>
<head>
<title>Search Results</title>
</head>

<body>

<cfsearch
collection="#Form.collname#"
name="getEmps"
criteria="#Form.Criteria#"
maxrows = "100">

<!--- Output the record set. --->
<cfoutput>
Your search returned #getEmps.RecordCount# file(s).
</cfoutput>

<cfoutput query="getEmps">
<p><table>
<tr><td>Title: </td><td>#Title#</td></tr>
<tr><td>Score: </td><td>#Score#</td></tr>
<tr><td>Key: </td><td>#Key#</td></tr>
<tr><td>Summary: </td><td>#Summary#</td></tr>
<tr><td>Custom 1:</td><td>#Custom1#</td></tr>
<tr><td>Column list: </td><td>#ColumnList#</td></tr>
</table></p>

</cfoutput>
</body>
</html>

Save the file as collection_db_results.cfm in the myapps directory under the web_root.
View collection_db_search_form.cfm in the web browser and enter the name of the collection and search terms.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 05-21-2007, 10:47 AM
Junior Member
 
Join Date: Oct 2006
Posts: 3
rameshuddaraju is on a distinguished road
Writing a query in ColdFusion

Quote:
Originally Posted by gogbpackrs2 View Post
how do i write a query in coldfusion?
By using coldfusion cfquery

Example

Your_DataSourceName : DSn name we created in Coldfusion server. which refers to your database.


<cfquery name="AnyName" datasource="Your_DataSourceName">

select empno,ename,sal from employee

</cfquery>

To display data from the above query

<table>
<cfoutput query="AnyName">

<tr><td> #empno# </td><td>#ename#</td><td>#sal#</td></tr>

</cfoutput>

</table>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new questions
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
How to find second max sal of employee with the co chandraismoon Oracle Tutorials 7 05-16-2008 03:08 AM
Criticisms Of ColdFusion encoder Coldfusion 0 05-06-2006 08:07 PM
comp.lang.c Answers (Abridged) to Frequently Asked Questions (FAQ) Steve Summit Tech FAQ 0 06-15-2004 06:00 AM
comp.lang.c Answers to Frequently Asked Questions (FAQ List) Steve Summit Tech FAQ 0 06-01-2004 06:00 AM
comp.lang.c Answers (Abridged) to Frequently Asked Questions (FAQ) Steve Summit Tech FAQ 0 05-15-2004 06:00 AM


All times are GMT -4. The time now is 06:32 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2004 - 2007 Exforsys Inc. All rights reserved.