DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2004
    Location
    UK
    Posts
    185

    Question output SQL result to CSV file

    Hi all i have the following code in my VB6 program.

    My program asks for a date then runs the following query.

    e.g.
    SELECT * from table ORDERS where DateCreated = 28/06/06.

    How could i output the result to a CSV file?

    Thanks
    Thankyou

  2. #2
    Join Date
    Dec 2003
    Posts
    2,750
    Code:
    Dim cnn As New ADODB.Connection
    Dim strSQL As String
    
    cnn.Open _
       "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                         "Data Source=e:\My Documents\DB1.mdb;" 
    
    strSQL = "SELECT * INTO [Text;DATABASE=e:\My Documents\TextFiles].[Orders.csv] FROM [Orders] WHERE DateCreated = #06/06/2006#"
    
    cnn.Execute strSQL
    
    cnn.Close
    Paul
    ~~~~
    Microsoft MVP (Visual Basic)

Similar Threads

  1. Output Text File
    By Hutty in forum .NET
    Replies: 2
    Last Post: 05-19-2006, 11:01 PM
  2. Addition of database file in SQL Server 7.0
    By madhu p menon in forum Database
    Replies: 3
    Last Post: 02-11-2002, 10:19 AM
  3. NullPointerException when reading text file
    By Andrew McLellan in forum Java
    Replies: 3
    Last Post: 05-09-2001, 05:34 PM
  4. Problems with NetAddUser
    By Jeff Morgan in forum VB Classic
    Replies: 2
    Last Post: 02-13-2001, 10:49 AM
  5. Output SQL results to excel
    By Nicola McCarthy in forum Database
    Replies: 3
    Last Post: 12-26-2000, 04:39 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links