Re: Populate dataset with text file



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)


.



Relevant Pages

  • Re: Tables and inserting rows
    ... endorsements would populate for that 1 vehicle. ... Is it possible to rename the bookmark or do I have to use the other option ... Dim myDataBase As Database ... Dim myActiveRecord As Recordset ...
    (microsoft.public.word.vba.general)
  • Re: Tables and inserting rows
    ... I have the main template and then am inserting a document which has all the ... Dim myDataBase As Database ... Dim myActiveRecord As Recordset ... 'Add a row to the table and populate the cells in that row with the ...
    (microsoft.public.word.vba.general)
  • Re: Tables and inserting rows
    ... bookmark (rather than try and do something with autotext). ... Dim myDataBase As Database ... Dim myActiveRecord As Recordset ... 'Add a row to the table and populate the cells in that row with the ...
    (microsoft.public.word.vba.general)
  • Re: Tables and inserting rows
    ... Dim myDataBase As Database ... Dim myActiveRecord As Recordset ... 'Add a row to the table and populate the cells in that row with the data ... Set drow = dtable.Rows.Add ...
    (microsoft.public.word.vba.general)
  • Re: Tables and inserting rows
    ... The following code will populate a table with data from an Access database: ... Dim myDataBase As Database ... Dim myActiveRecord As Recordset ... Set drow = dtable.Rows.Add ...
    (microsoft.public.word.vba.general)