开发者

how to update a selected record in a dataset and update another datatable in another Adoconnection?

I have 2 adoconnections and 2 datatables in each connection (Local Table1_master Table1_Detail) (Network Table1_master Table1_Detail). I show them开发者_JS百科 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜