Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exporting text from ADO rst

Status
Not open for further replies.

Mats

Technical User
Feb 18, 2000
83
EU
This is more of a general question...

What would be a good way to handle data to be exported to a text file? I often need to create a procedure that exports records into a specified format(fixed lenghts, decimals, padding zeroes etc.) Now I always write specific code to go trough every record and format it the way I want before writing to the textfile.

What I'm looking for is the shortest way from a recordset to a exported textfile in a specified format.

Any help is much appreciated.

Mats

 
What if you created a file that your application read in and you could set up the criteria and format of the data. You could put this in an INI file or and XML file or just a file format that you parse. It might look something like this if it was an INI file:

[OutputFile]
FileName=Employees.txt

[DataSource]
DSN=MyDatabase

[SQL]
Statement=SELECT Name, Address, City, State, Zip, Phone FROM EMPLOYEE ORDER BY Name

[Fields]
Field1=Name,,
Field2=Address,,
Field3=City,,
Field4=State,,
Field5=Zip,#####-####
Field6=Phone,(###) ###-####

Then all your application would have to do is read the format of the INI file and it would create the file for you. It would keep you from having to recode the appliaction for each instance. The code to do this is basically the same. You just pull the unique things out of the appliaction and put them in the file. All the common stuff stays in the application, like opening a recordset and writting to a file. Snaggs
tribesaddict@swbell.net
2 wire mesh butchering gloves:
1 5-finger, 1 3-finger, pair: $15
 
Thanks,

Sounds like an idea worth trying.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top