Solved

Export Records To Tab Delimited File Using ASP

Posted on 2008-06-20
5
815 Views
Last Modified: 2012-05-05
I have a table of date (products) which i need to export to a CSV file with the click of the a button.  This will generate the tab delimited file on the server which is then picked up automatically by another application.

My question is how to write this script to create the text file.  I have full access to the server to create permissions etc.

Basically my code would be something like the code snippet attached, the bit where i have TextFile.AddNew is the part i dont know how to do.

Regards,
Carl

<%
Set RS = Server.CreateObject("ADODB.Recordset")
SQL = "SELECT * FROM tblTempProducts"
RS.Open SQL,Connection,3,3
Do While Not RS.EOF
 TextFile.AddNew
   ProductID, ProductName, Price, TaxRate, Weight
 TextFile.Update
RS.MoveNext
Loop
RS.Close
Set RS = Nothing
SQL = " "
%>

Open in new window

0
Comment
Question by:net-workx
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 15

Expert Comment

by:dosth
ID: 21832835
0
 
LVL 29

Accepted Solution

by:
rdivilbiss earned 500 total points
ID: 21832923
More specifically.
<%
Dim fso, TextStream, path, fldr, Folder
 
Set fso = Server.CreateObject("Scripting.FileSystemObject")
path = Server.MapPath("/pathtofile/")
Set fldr = fso.GetFolder(path)
Set TextStream = fldr.CreateTextFile("test.txt")
Set RS = Server.CreateObject("ADODB.Recordset")
SQL = "SELECT * FROM tblTempProducts"
RS.Open SQL,Connection,3,3
Do While Not RS.EOF
	TextStream.WriteLine  rs("ProductID") & chr(9) & rs("ProductName") & rs("Price") & chr(9) & rs("TaxRate") & chr(9) & rs("Weight")
rs.movenext
loop
RS.Close
Set RS = Nothing
SQL = " "
TextStream.Close

Open in new window

0
 
LVL 29

Expert Comment

by:rdivilbiss
ID: 21833008
0
 

Author Closing Comment

by:net-workx
ID: 31469215
Thanks for your prompt response, exactly what i needed - a nice and easy to follow guide to get me started....  
0
 
LVL 29

Expert Comment

by:rdivilbiss
ID: 21837972
Thank you for the points and good luck with your project.
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
randomize data from excell cell 15 50
WMIC Output Formatting 1 46
VB script help 23 32
SP converting date time to date and time separately 2 17
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Running classic asp applications under Windows Server 2008 R2 (x64) and IIS 7 is not as easy as one may think. It took me a while to figure it out while getting error 8002801d a few times. After you install the OS you will need to install the fol…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question