Board index » delphi » ADO DataSet Append

ADO DataSet Append

Hi All

I have created a simple form which has two grids displaying records of
tables from two different Access mdb files. I would like to append the
selected records from the one table to the other. I am using Delphi5 with
the ADO components.

Can someone please help me.
Thanks
Peter

 

Re:ADO DataSet Append


AFAIK you will have to write a query or append the records 1 at a time to the
destination table to do this. If anybody can come up with a better solution I
will be interested.

Re:ADO DataSet Append


AFAIK you will have to write a query or append the records 1 at a time to the
destination table to do this. If anybody can come up with a better solution I
will be interested.

Re:ADO DataSet Append


I had suggested a solution to this kind of problem and in that case it
was from oracle to access or access to oracle (don't remember which).
In any case, I would always use the sql route and I am going to show 2
examples, example 1 is the generic solution and example 2 is for access
2000 only.

1) from table1 to table2 (via a text file MyTextFile.txt)
use a query connected to the ADOConnection (Database containing Table1)
to create records in MyTextFile.txt in C:\temp directory
('SELECT * INTO MyTextFile#txt IN "c:\Temp" "Text;" FROM Table1');  
use a second query connected to the Database that contains table2
('INSERT INTO Table2 SELECT * FROM [MyTextFile#txt] IN "C:\Temp"
[TEXT;]');
and that's the data imported into table2.
It has been assumed that Table2 already exists (defined) in the
database.

2) From table1 to table2 direct assuming both databases are MS Access
2000 or MS Access 97 (i.e. they are of the same type)
e.g.
 Table1 is in db C:\ThePath\TheFirst.mdb
 Table2 is in db C:\OtherPath\YourFile.mdb

The query component is connected to the database containing table1, the
SQL is
'SELECT * INTO Table2 IN "C:\OtherPath\YourFile.mdb" FROM Table1'

The query connected to the database containing table2, the SQL is
INSERT INTO Table2 SELECT * FROM [Table1] IN "C:\ThePath\TheFirst.mdb")
note: the term query component here could be either a) TADOQuery or
b)TADODataSet
in the case of a) the SQL property is used
and in the case of b) the CommandText property is meant

Hope This Helps

In article <392BB07D.1C37E...@guardbase.co.uk>, Paul Tugwell
<pa...@guardbase.co.uk> writes

Quote
>AFAIK you will have to write a query or append the records 1 at a time to the
>destination table to do this. If anybody can come up with a better solution I
>will be interested.

--
Arnold Johnson

Other Threads