How to display sql query in web browser

New Here ,
Feb 15, 2021 Feb 15, 2021

Copy link to clipboard

Copied

Please let me know how to display the query written in cold fusion page on web browser.

Views

47

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Feb 15, 2021 Feb 15, 2021

Copy link to clipboard

Copied

I'm not entirely clear what you're asking. If you want to output the actual SQL statement, it's a property of the CFQUERY resultset, like so:

 

<cfquery name="sample" result="sampleResult" ...>

select * from tblSample

</cfquery>

 

<cfoutput>#sampleResult.sql#</cfoutput>

 

If on the other hand, you want to output the resultset itself, you use the QUERY attribute of CFOUTPUT:

 

<cfquery name="books" ...>

select bookId, name, author from tblBooks

</cfquery>

 

<cfoutput query="books">

#name#, #author#<br>

</cfoutput>

 

Dave Watts, Eidolon LLC

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Feb 16, 2021 Feb 16, 2021

Copy link to clipboard

Copied

ColdFusion comes with a built-in datasource called cfartgallery. So, if  you open the following page, it will display the query in the browser.

 

testPage.cfm

<cfquery datasource="cfartgallery" name="testQuery">
select *
from artists
</cfquery>

<cfdump var="#testQuery#">

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 18, 2021 Feb 18, 2021

Copy link to clipboard

Copied

LATEST

Thank a lot BKBK and others for the solutions provided by you all.  I am trying to print the dynamic query which i will writing in my .cfm page on to the browser.  Will test the sample code provided by BKBK.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines