Re: Populate dataset with text file
- From: "Dan Rock" <danno492_NOSPAM@xxxxxxxxxxx>
- Date: Tue, 23 Aug 2005 08:23:41 -0400
I have found this code snippet on about.com, but it does not work for me
using Advantage as my database server.
It appears that it would work fine, but if you could tell me the right
syntax, maybe it would solve the issue???
Connect a TADOCommand to your database using the ConnectionString or the
Connection (TADOConnection) property. Assign the next string for the
CommandText property of the ADOCommand object:
'INSERT INTO TableName (FieldName1, FieldName2) SELECT * FROM
[asciidata.txt] in "C:\SomeFolder" "Text;HDR=Yes;"'
Call the Execute method of the ADOCommand object.
Note:
1.. Replace asciidata.txt with the name of the text file you want to get
data from.
2.. Replace C:\SomeFolder with the name of the folder where the text file
is saved.
3.. The first row in the text file will be used as column headings/field
names. Make column titles rom the text file match the table field names.
4.. Each column with data must be separated with the list separator
character that is used in the regional settings in the Control Panel.
That's all. No need to load the asciidata.txt file and create a loop to call
the INSERT statement for each data row.
"Bill Todd" <no@xxxxxx> wrote in message
news:430b0d64$1@xxxxxxxxxxxxxxxxxxxxxxxxx
>
> Dan Rock wrote:
>
>> Commenting out the inserts, It takes about 45 seconds to populate a
>> text box one row at a time. If I use Memo1.Lines.LoadFromFile I can
>
> I assume that the 45 seconds includes assigning each record to the
> TStringList.DelimitedText property to parse it. If so that proves that
> the performance problem is not with the import but with inserting the
> records into the database.
>
>> populate a memo control in less than a second.
>
> That is a meaningless comparison since most of the time required by the
> import is the time to parse the record on the asterisk delimiter and
> loading the file into a memo does not do this.
>
>>
>> If I can find a way to simple either make a temp table or populate an
>> existing table using the asterisk as a field delimiter, I am thinking
>> it should take considerably less time than populating a dataset one
>> record at a time.
>
> What component are you using to insert the record? If you are using a
> query component, what is the SQL?
>
> It might help to see the actual code.
>
> --
> Bill Todd (TeamB)
.
- Follow-Ups:
- Re: Populate dataset with text file
- From: Bill Todd
- Re: Populate dataset with text file
- From: Vitali Kalinin
- Re: Populate dataset with text file
- References:
- Populate dataset with text file
- From: Dan Rock
- Re: Populate dataset with text file
- From: Bill Todd
- Re: Populate dataset with text file
- From: Dan Rock
- Re: Populate dataset with text file
- From: Bill Todd
- Re: Populate dataset with text file
- From: Dan Rock
- Re: Populate dataset with text file
- From: Bill Todd
- Re: Populate dataset with text file
- From: Dan Rock
- Re: Populate dataset with text file
- From: Bill Todd
- Re: Populate dataset with text file
- From: Dan Rock
- Re: Populate dataset with text file
- From: Bill Todd
- Populate dataset with text file
- Prev by Date: Re: Populate dataset with text file
- Next by Date: Problem with field name that uses #
- Previous by thread: Re: Populate dataset with text file
- Next by thread: Re: Populate dataset with text file
- Index(es):
Relevant Pages
|