I am looking for the simplest way to write to a .txt file, that has a seperate header area, subhead area, and single entries. The data needs to pull from tables in a SQL database and from pre defined values.
Can anyone help?
Thanks.
Printable View
I am looking for the simplest way to write to a .txt file, that has a seperate header area, subhead area, and single entries. The data needs to pull from tables in a SQL database and from pre defined values.
Can anyone help?
Thanks.
Can you give us an example of what you are looking for? (Formatting)
Here is a sample of what I am going after:
101 07500005113918269450458081136A094101MARTIN & KINGSLY BANK ABS SERVICES INC
5200ABS SERVICES INC 1391830098PPDLOAN PYMT 050808050808 1075000050000001
62729147959214000202 0000049243NMB00001 SCHMIDT, SARA A. RA0075000050000001
820000113100920707970000599142600000599142601391826998 075000050000001
9000001000114000011310092070797000200914260000059914260
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
Please expain what this sample means. which is head, subhead etc
Well a good way to do so is by usage for IO.StreamWriter.Quote:
Originally Posted by callydata
Peudo code:
Hope it help!Code:Open File using IOStreamWriter
WriteFileHeader()
Do Loop for all record
' Write This product header
Do Loop Until The Same product
' Write Product Detail from the current record
Loop
' Write This product footer
Loop
WriteFileFooter()
Close IO.StreamWriter
PS
I use Product just as exemple I can't be anything else
Header:
101 07500005113918269450458081136A094101MARTIN & KINGSLY BANK ABS SERVICES INC
SubHead:
5200ABS SERVICES INC 1391830098PPDLOAN PYMT 050808050808 1075000050000001
Entry:
62729147959214000202 0000049243NMB00001 SCHMIDT, SARA A. RA0075000050000001
Footer:
9000001000114000011310092070797000200914260000059914260
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
So some of this content will be constant, and other parts of the content will be pulled from a table.
Any ideas are appreciated!
Simple....
VB Code:
Dim oFile As System.IO.File Dim oWrite As System.IO.StreamWriter 'creates text file oWrite = oFile.CreateText(...pathtofile... ex. "c:\mydata.txt"...) 'writes data by line oWrite.WriteLine(...header...) oWrite.WriteLine(...sub header...) oWrite.WriteLine(...data...) 'flushes data to file and closes it oWrite.Close()
NOt so fast gigemboy....
some of the info should be pulled from a table, what kind of statement would that be?VB Code:
oWrite.WriteLine(...sub header...)
thanks!!
That was the code to write the info to the text file once you got it over from the data tables... 'tis all.. should've written it on there.. but I thought it was evident :)
Pulling data from SQL tables is going to require data access contstructs, sql queries, etc... not a particulary "easy" task.. better to find a link to read up on it.. I don't have any off hand, and haven't "delved" into the matter at all... maybe someone else can post a good link...
Yeah if you know some in ADO.NET then you could fetch the data in sql put in a datatable then loop to your datatable for writing to the txt file.