473,385 Members | 1,396 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Append text records and post


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
3 2440
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Larry Rekow | last post by:
In Access I have a macro that, each night, takes a table with a primary key defined in it, and deletes all the rows. Then it imports/appends records from a fixed width text file. In this way,...
3
by: Jonathan Buckland | last post by:
Can someone give me an example how to append data without having to load the complete XML file. Is this possible? Jonathan
2
by: JMCN | last post by:
hi i have a general question regarding append queries in access 97. each week i need to update my table(tblonlinereg) with new or modified records. firstly, i import the text file into my...
3
by: JOEP | last post by:
What do I need to do to allow an append query to post null values to records in a field of the destination table? Basically I want to allow records with null values to post to the table. The append...
22
by: RayPower | last post by:
I'm having problem with using DAO recordset to append record into a table and subsequent code to update other tables in a transaction. The MDB is Access 2000 with the latest service pack of JET 4....
4
by: MN | last post by:
I have to import a tab-delimited text file daily into Access through a macro. All of the data needs to be added to an existing table. Some of the data already exists but may be updated by the...
3
by: wvmbark | last post by:
First time poster... I just found this forum and it appears there's plenty of people here that could make short work of problem that's been driving me absolutely bonkers for months. Every day we...
7
by: wade.wall | last post by:
Hi all, I am having a problem appending data to an existing table. I have two tables with identical fields and I want to append the data from one table (T2) to the first (T1). T1 has 136...
0
by: Filio | last post by:
Hi all: My problem is a little different than the earlier append table post. I have T1 with an autonum field as the primary key, and T2 with identical fields as the first, but no autonum. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.