Delphi使用1个保存按钮保存来自不同数据源的所有值 [英] Delphi save all values from different datasources with 1 save button
本文介绍了Delphi使用1个保存按钮保存来自不同数据源的所有值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我收到了这张表格;
我想使用1个保存按钮来保存所有这些修改.但是问题在于这些字段都具有不同的数据源.有人可以帮我吗?
I want to save al of those edits with 1 save button. But the problem is that those fields all have a different datasource. Is there somebody who can help me out?
推荐答案
简单地遍历所有涉及的数据源,并使用 DataSource.DataSet.Post
(假设数据集已经在 dsEdit
/ dsInsert
模式).
Simple go over all data sources involved and use DataSource.DataSet.Post
(assuming the DataSets are already in dsEdit
/dsInsert
mode).
注意: :如果您的DBMS支持事务,明智的做法是将所有帖子归为一个事务,这样就不会损害数据/关系的完整性,例如:
Note: If your DBMS supports transactions, it would be wise to group all your posts in a single transaction, so that data/relations integrity will not be compromised e.g.:
MyConnObj.BeginTrans;
try
DataSource1.DataSet.Post;
DataSource2.DataSet.Post;
DataSource3.DataSet.Post;
MyConnObj.CommitTrans;
except
MyConnObj.RollbackTrans;
raise;
end;
这篇关于Delphi使用1个保存按钮保存来自不同数据源的所有值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文