简体   繁体   English

是否有多个TDataSource引用一个TDataSet后代组件是可能且安全的?

[英]Is it possible and safe to have multiple TDataSources reffering one TDataSet descendant component?

I'm designing database app with ZeosLib. 我正在用ZeosLib设计数据库应用程序。 On one form I have some Lookups that should refer to the same dataset. 在一种形式上,我有一些查找应引用相同的数据集。 Is it safe to create one TDataSet descendant and then connect few TDataSources to it ? 创建一个TDataSet后代然后将几个TDataSource连接到它是否安全?


Thanks for your answers. 感谢您的回答。

One more question: Is it a good programming practice to have such layout : 还有一个问题:具有这样的布局是否是一种好的编程习惯:

TDataSet (lookup items TZQuery) (fields ID,A,B)
                 |
                 +----> TDataSource ------> Lookup compo listing field A and returning ID
                 |
                 +----> TDataSource ------> Lookup compo listing field B and returning ID
                 |
                 ...

What about lookups in TDBCtrlGrid ? TDBCtrlGrid中的查询呢? I know that Delphi explicitly disables this opportunity, but my research proves that this is possible. 我知道Delphi明确禁用了这个机会,但是我的研究证明这是可能的。 I've created csReplicatable descendant of TCustomComboBox with TDataFieldLink and one DataSource as Listsource, and actually it works ok, so I don't understand such limitation. 我用TDataFieldLink和一个DataSource作为Listsource创建了TCustomComboBox的csReplicatable后代,并且实际上工作正常,所以我不理解这种限制。 Where it comes from ? 它来自哪里?

It is not only possible but advisable to use one dataset for all datasources which display the same information. 对于所有显示相同信息的数据源,不仅可能而且建议使用一个数据集。 The dataset keeps the data and the datasources keeps the positioning information (cursor) required by data aware components. 数据集保留数据,数据源保留数据感知组件所需的定位信息(光标)。

I think with lookuptables it should be save, since it doesn't really matter where in the dataset the cursor is positioned. 我认为应该使用lookuptables保存它,因为光标在数据集中的位置并不重要。 I'd say: give it a try! 我会说:试试看!

It is safe but why not just have one TDataSource connected to the one TDataSet? 这是安全的,但是为什么不只将一个TDataSource连接到一个TDataSet呢? They'll all do the same thing. 他们都会做同样的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM