result of SQL statements, should be output it to a text file

result of SQL statements, should be output it to a text file

Post by Latife Habi » Sun, 08 Jul 2001 05:11:00



hi,

I have a problem with my code.
can you please help me.

here is my problem:

I have an SQL statement is to select data from a query. then I want it to
display the result of the SQL statement into a text file.

I have a combo box and a text1 box
combo box it has "Company"

I am going to copy and paste my code.
please, help me with this.

************************************
If Combo2 = "Company" Then
strSQL = "Select lname,finame,st,state,zip,idss
from coquery where idss = '" & Text1.Text & "'"
    MsgBox "it work Company"
    rs.Source = strSQL
    rs.Open
    Open App.Path & "\data.txt" For Output As #1
    Write #1, lname, finame

note: how can I take the fields that are generated from the select statement
and writes them to a text file

thank you

 
 
 

result of SQL statements, should be output it to a text file

Post by Philip Meek » Sun, 08 Jul 2001 06:01:41



Quote:

> hi,

> ************************************
> If Combo2 = "Company" Then
> strSQL = "Select lname,finame,st,state,zip,idss
> from coquery where idss = '" & Text1.Text & "'"
>     MsgBox "it work Company"
>     rs.Source = strSQL
>     rs.Open
>     Open App.Path & "\data.txt" For Output As #1
>     Write #1, lname, finame

> note: how can I take the fields that are generated from the select
statement
> and writes them to a text file

I guess the first thing you have to decide is how you want to seperate the
fields.  I wouldn't recommend fixed width because if you have any varchar
fields in the database, the data you get back will be only the width of the
data, not the padded width of the field.

I would try something like this using a tab delimiter:

Dim sOut as string
Dim FieldCount as long

do until RS.EOF
    sOut = ""
    for FieldCount = 0 to (Rs.Fields.Count - 1) ' the field count is one
based, but the indexing is 0 based
        sOut = sOut & Rs.Fields(FieldCount)
        if FieldCount < (Rs.Fields.Count) then
            sOut = sOut & vbTab
        endif
    next FieldCount
    Write #1, sOut
    rs.MoveNext
loop

Philip Meeks
ETV Technologies

 
 
 

1. output query results to a text file

Hello all,
I am trying to write a sproc that I can schedule as a Scheduled Task in SQL
Server 6.5.   How can I save the output to a text file?

I know how to email the results of a query but can't for the life of me
figure out how to write out to a file.  I'm sure I am missing something very
basic and am hoping someone can point me in the right direction.

Many thanks,
Deb Joyce

2. [COMMITTERS] pgsql/contrib/pg_dumplo (README.pg_dumplo lo_export.c lo_import.c main.c pg_dumplo.h utils.c)

3. How to output results onto a TEXT file?

4. Loosing a connection over router on SQL 7.0

5. Output result into text file

6. Help will software agreement....please..

7. Outputting results to a text file

8. Equivalent of Oracle's Connected By

9. Output Query Result to Text File with BCP

10. Output query result to a text file?

11. Output Query Results to Text File

12. Outputting results to a text file

13. Oracle8i stored procedures - output result to text file