tags:

views:

59

answers:

1

I have 2 adoconnections and 2 datatables in each connection (Local Table1_master Table1_Detail) (Network Table1_master Table1_Detail). I show them in a DBgrid and now I would like to update the (Local Table1_master Table1_Detail) from the tables in (Network Table1_master Table1_Detail). How can I update the selected records?

I have tried many ways but normally it inserts more records and doesn´t update the record.

I use a .MDB database.

A: 

You could use an old master -> new master approach. Return both datasets sorted the same way, and run down each list simultaneously. if table1.key > table2.key then you have a record in table2 that doesn't exist in table1...you can delete the record in table2 or increment the cursor. If table1.key < table2.key then you are missing a record in table2, so insert the new record. if table1.key = table2.key then you can perform your update logic. if table1 is at end but table2 is not, then the rest of table2 doesn't exist in table1 (so possible deletes). If your at the end of table2, but not at the end of table1, then the rest of table1 are inserts.

The nice thing about this approach is you only walk each table once, and its in the same loop.

skamradt
for me a try many thing but that one maybe work is it the best way to do that for the master and detail table?is there a code that i can stady.. Thank youTableMaster(metria_Sub_Sub)numeracao_sub long AUTOnumeracao long Foto1 text(50) Foto2 text(50) Analisefoto1 text(50) Observações memo YObra text(250) Designação_equipamento text(250)DetailTablenumeracao_sub_EQ long AUTOnumeracao_sub long Designação_equipamento text(250) Tensão text(50) Potençia text(50) Tipo_equipamento text(50) Localização text(50) Foto_PontosMed text(50) InterruptorDiferencial text(50)
ml