
Export query results to text file
I'll assume also that you don't want to automate Access (Access has a
particularly handy macro called TransferText that does this quite well.)
But because you posted this in a VB/ADO newsgroup, I'll give you the ADO
code.
Here's but one approach:
'--Begin Sample Code
Dim oCn As New ADODB.Connection
Dim oRs As New ADODB.Recordset
oCn.Open "provider=sqloledb;data source=(local);user id=me;initial
catalog=northwind;"
oRs.Open "SELECT * FROM CATEGORIES", oCn
Open "c:\categories.txt" For Output As #1 ' Open file for input.
Do Until oRs.EOF
Write #1, oRs("CategoryID").Value, oRs("CategoryName").Value '<more
can be added, separated by commas
oRs.MoveNext
Loop
oRs.Close
oCn.Close
Set oRs = Nothing
Set oCn = Nothing
'--End Sample Code
Hope this helps!
Steven Bras, MCSD
Microsoft Developer Support/Visual Basic WebData
This posting is provided AS IS with no warranties, and confers no rights.
You assume all risk for your use. ? 2001 Microsoft Corporation. All rights
reserved.