Board index » delphi » Copy data between tables with different mdbs

Copy data between tables with different mdbs

Quote
> Do you have any quicker method to handle this task?

Can you do something like DataSet1 := DataSet2 and then write DataSet1 to
the database 1?

Lauchlan M.

 

Re:Copy data between tables with different mdbs


I use Delphi 5 & Access 2k as database.
I have two mdb files (A.mdb and B.mdb).  There are ten same data structure
tables in these mdbs (A1, .., A10 in A.mdb & B1, .., B10 in B.mdb).  Their
no. of fields is range from 10 to 120.
Now, I want to copy data from A1 to B1.  I use the following method:
First, I use two ADOConnections to connect two mdbs.
Then I use ten ADODataSets to access ten tables and connect to the
corresponding ADOConnection.
Afterthat, I copy data from A1 to B1, A2 to B2, ..., A10 to B10 field by
field.
For example,
for i := 0 to A1.FieldCount-1 do
  B1.FieldByName(A1.Fields[i].FieldName).Value := A1.Fields[i].Value;
Finally, the performance of this method is very poor.
Do you have any quicker method to handle this task?

Thanks.

Re:Copy data between tables with different mdbs


Quote
"Zero" <shin...@hongkong.com> wrote in message news:3cda77af_2@dnews...
> I use Delphi 5 & Access 2k as database.
> I have two mdb files (A.mdb and B.mdb).  There are ten same data structure
> tables in these mdbs (A1, .., A10 in A.mdb & B1, .., B10 in B.mdb).  Their
> no. of fields is range from 10 to 120.
> Now, I want to copy data from A1 to B1.  I use the following method:
> First, I use two ADOConnections to connect two mdbs.
> Then I use ten ADODataSets to access ten tables and connect to the
> corresponding ADOConnection.
> Afterthat, I copy data from A1 to B1, A2 to B2, ..., A10 to B10 field by
> field.
> For example,
> for i := 0 to A1.FieldCount-1 do
>   B1.FieldByName(A1.Fields[i].FieldName).Value := A1.Fields[i].Value;
> Finally, the performance of this method is very poor.
> Do you have any quicker method to handle this task?

Select Into "C:\PathandDBName" From "C:\PathandDbName">

Re:Copy data between tables with different mdbs


Quote
>I use Delphi 5 & Access 2k as database.
>I have two mdb files (A.mdb and B.mdb).  There are ten same data structure
>tables in these mdbs (A1, .., A10 in A.mdb & B1, .., B10 in B.mdb).  Their
>no. of fields is range from 10 to 120.
>Now, I want to copy data from A1 to B1.

You can do an Insert query from one databaes to the other.  Like this

INSERT  INTO TableA
 (Select SomeFields From TableB IN 'C:\MyFolder\MyDatabase.MDB' )
--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:Copy data between tables with different mdbs


Hi Zero,

Quote
> I use Delphi 5 & Access 2k as database.
> I have two mdb files (A.mdb and B.mdb).  There are ten same data structure
> tables in these mdbs (A1, .., A10 in A.mdb & B1, .., B10 in B.mdb).  Their
> no. of fields is range from 10 to 120.
> Now, I want to copy data from A1 to B1.

You can do that with a single TADOConnection.

If you are connected to database A:
INSERT INTO B1 IN 'C:\Myfolder\B.MDB' SELECT SomeFields FROM A1;

If you are connected to database B:
INSERT INTO B1 SELECT SomeFields FROM A1 IN 'C:\Myfolder\A.MDB' ;

Thrse

Other Threads