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