Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 168
  • Last Modified:

Save Query as text

I have a chart displayed on a page. The chart is drawn using criteria from a form that the Customer completes. The data for the chart is kept in a SQL Server 7 db. How do I save the results of the query as a file and allow the user to download it?
0
cb1
Asked:
cb1
  • 2
1 Solution
 
nathansCommented:
Here is a sample on how it can be done.  Of course you need to change the query information.  If you need more help comment and I will try and help you.

<html>
<head>
      <title>Untitled</title>
</head>

<body>


<!--- This is just an example --->

<cfquery name="SampleQuery" datasource="nsnd">
select             *
from                   users
</cfquery>

<cfset loginname ="blank">
<cfoutput query="SampleQuery">
<cfset ListName = "#loginname#">

<cffile action="append" file="D:\inetpub\wwwroot\test\file.txt"  output="#listname#">

</cfoutput>
<a href="/test/file.txt">File</a>

</body>
</html>
0
 
cb1Author Commented:
Can you explain the <cfset loginname ="blank"> and how would I allow the user to download the results as opposed to showing them on screen.

Thanks
0
 
nathansCommented:
1. You don't need the  <cfset loginname ="blank">  sorry I modified some code I have that works... and I needed it for a list.  I was creating a comma delimited list and I started with the first one as blank.

2.Since it is text it really depends on how you want the user to do it.

  A) you can name it something other then .txt like .dat or
  B) you can tell them how to right click and download the file.  

Not sure which works best for your situation but that is some of the choices I would be looking at.


Nathan Stanford
What else can I help you with?
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now