How can I update a selected record in a dataset and update a different datatype in another Adoconnection?
I have 2 adoconnections and 2 datatables in each connection (Local Table1_master Table1_Detail) (Network Table1_master Table1_Detail). I am showing them in DBgrid and now I would like to update (Local Table1_master Table1_Detail) from tables in table (Table1_master Table1_Detail). How can I update selected records?
I have tried many ways, but usually it inserts more records and does not update the record.
I am using a .MDB database.
source to share
You can use the old master -> new master approach. Return both datasets sorted the same and loop through each list at the same time. if table1.key> table2.key then you have an entry in table2 that doesn't exist in table1 ... you can delete the entry in table2 or increase the cursor. If table1.key <table2.key, then you are missing a record in table2, so insert a new record. if table1.key = table2.key then you can do your update logic. if table1 ends but table2 does not, then the rest of table2 does not exist in table1 (possibly dropped). If you are at the end of table2 but not at the end of table1, the rest of table1 is inserts.
The best part about this approach is you only project each table and it into the same loop every time.
source to share