|
-
Sep 13th, 2005, 02:16 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Write to a .txt file & some other things....
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.
-
Sep 13th, 2005, 02:19 PM
#2
Lively Member
Re: Write to a .txt file & some other things....
Can you give us an example of what you are looking for? (Formatting)
"I aim to misbehave."
Captain Mal Reynolds
-
Sep 13th, 2005, 02:29 PM
#3
Thread Starter
Addicted Member
Re: Write to a .txt file & some other things....
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
-
Sep 13th, 2005, 02:44 PM
#4
Hyperactive Member
Re: Write to a .txt file & some other things....
Please expain what this sample means. which is head, subhead etc
-
Sep 13th, 2005, 02:54 PM
#5
Re: Write to a .txt file & some other things....
 Originally Posted by callydata
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.
Well a good way to do so is by usage for IO.StreamWriter.
Peudo code:
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
Hope it help!
PS
I use Product just as exemple I can't be anything else
-
Sep 13th, 2005, 03:13 PM
#6
Thread Starter
Addicted Member
Re: Write to a .txt file & some other things....
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!
-
Sep 13th, 2005, 03:58 PM
#7
Re: Write to a .txt file & some other things....
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()
-
Sep 13th, 2005, 04:11 PM
#8
Thread Starter
Addicted Member
Re: Write to a .txt file & some other things....
NOt so fast gigemboy....
VB Code:
oWrite.WriteLine(...sub header...)
some of the info should be pulled from a table, what kind of statement would that be?
thanks!!
-
Sep 13th, 2005, 04:19 PM
#9
Re: Write to a .txt file & some other things....
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...
-
Sep 13th, 2005, 08:06 PM
#10
Re: Write to a .txt file & some other things....
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|