By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,001 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

Append text records and post

P: n/a

Hello,

I'll bet this is an elementary question. I have a text file I am
converting and posting to a SQL database. But the first 15 records in
this text file are going into a NOTES field in the SQL db and I want to
append all of these together before I post to the database. In other
words, I don't want to create 15 records, just one. How do I append the
records and then write the appended record to the database? I can look
at it with a loop:

if detail("UNIT")='X' then
do while not detail.eof
NOTES=detail("NOTES") & " "
response.write NOTES
detail.movenext
loop
end if

But I'm lost after that. Thank you for your thoughts.

Charles Ranch

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Two loops.

In the first one, read the text file one line at a time and loop. Use a loop
counter and while it is still less then or equal to 15, concatenate all the
line's data and add the whole thing to the Notes field.

When the counter passes 15 call the second loop which puts each subsequent
line into the proper Field until you hit the end of file.
--

Phillip Windell [MCP, MVP, CCNA]
www.wandtv.com
"Charles Ranch" <ne********@hotmail.com> wrote in message
news:#P**************@TK2MSFTNGP09.phx.gbl...

Hello,

I'll bet this is an elementary question. I have a text file I am
converting and posting to a SQL database. But the first 15 records in
this text file are going into a NOTES field in the SQL db and I want to
append all of these together before I post to the database. In other
words, I don't want to create 15 records, just one. How do I append the
records and then write the appended record to the database? I can look
at it with a loop:

if detail("UNIT")='X' then
do while not detail.eof
NOTES=detail("NOTES") & " "
response.write NOTES
detail.movenext
loop
end if

But I'm lost after that. Thank you for your thoughts.

Charles Ranch

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 19 '05 #2

P: n/a
On Tue, 23 Mar 2004 09:49:09 -0800, Charles Ranch
<ne********@hotmail.com> wrote:
I'll bet this is an elementary question. I have a text file I am
converting and posting to a SQL database. But the first 15 records in
this text file are going into a NOTES field in the SQL db and I want to
append all of these together before I post to the database. In other
words, I don't want to create 15 records, just one. How do I append the
records and then write the appended record to the database? I can look
at it with a loop:

if detail("UNIT")='X' then
do while not detail.eof
NOTES=detail("NOTES") & " "
response.write NOTES
detail.movenext
loop
end if

But I'm lost after that. Thank you for your thoughts.


Assuming it's a comma delimited file with CR/LF delineating a record,
you could simply open the file, read in 15 lines and save that as your
data. Maybe like:

strMyRecord = ""
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set FileText = objFSO.OpenTextFile("mydatafile.txt", 1)
For i = 1 to 15
strMyRecord = strMyRecord & FileText.ReadLine & VbCrLf
Next
readfile.close
Response.Write strMyRecord

You can parse the line after reading it to escape single quotes, do a
Server.HTMLEncode on it, do a Split at the commas for individual
fields or whatever you wish to do to format it for what you need.
Might need EOF checking, FileExists checking and other error trapping,
but you get the idea.

Jeff
Jul 19 '05 #3

P: n/a
Thanks to both of you. I'll give it a try. Thanks again.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.