How to write an asp script storing the result from a query in a CSV text 
Author Message
 How to write an asp script storing the result from a query in a CSV text

On Wed, 28 Mar 2001 19:59:44 GMT, "Jean-Marc PHILIP"

Quote:

>How to write an asp script storing the result from a query in a CSV text
>file ?

Jean-Marc,
Here is a complete working example of writing a CSV file from ASP!
Reply if you have any questions!


<%Option Explicit%>

<html>
<!-- #Include file = "..\..\Include\adovbs.asp"  -->

<head><title>Generic Report</title></head>
<body bgcolor="#ffffff" text="#000000">
<%
  dim person, sql, connection, field
  Dim objFSO
  Dim objFile

  Set objFSO = CreateObject ("Scripting.FileSystemObject")
  Set objFile = objFSO.CreateTextFile("C:\Inetpub\wwwroot\Report.csv")

  dim theDatabase
  theDatabase = "Driver={Microsoft Access Driver (*.mdb)};
DBQ=C:\Databases\Test.mdb"

  set connection = Server.CreateObject ("ADODB.connection")
  set person = Server.CreateObject ("ADODB.Recordset")

  sql ="SELECT person.recordNumber, person.last, person.first "   & _
       "FROM person "   & _
       "ORDER BY person.recordNumber ASC"

  connection.open theDatabase
  person.open sql, connection, adOpenKeyset, adLockReadOnly

  ' write the data
  while not person.eof
    objFile.WriteLine """" & person("first") & """,""" &
person("last") & """"
    person.moveNext
  wend

  response.write " Total Records = " & person.recordCount
  person.close
  set person    = nothing
  connection.close
  set connection = nothing
%>

</body>
</html>



Fri, 17 Sep 2004 03:32:55 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. DBCombo Initially Blank

2. Q: FindKey equivalent for dBASE indexes based on expressions

3. How to write an asp script storing the result from a query in a CSV text

4. How to write an asp script storing the result from a query in a CSV text file ?

5. Script to parse Outlook survey results to a .CSV file

6. No current record

7. BP7 : internal error on Win2000 ?

8. D3 : How to free the resources... NEED SOME HELP!!

9. Shareware equivalents to Infopower DBGrid?

10. Direct ASP query results to Excel?

11. Need help with printing results from an SQL query in ASP VBScript

12. Query works fine in Enterprise Manager, no results from asp

 

 
Powered by phpBB® Forum Software