Can I search from two datasets at the same time?

In this question , I asked about splitting the dataset into subsets and got a good answer. Now I have the opposite problem. I have two different datasets representing objects of two different subclasses of a common ancestor, and I need to use the same TDBLookupComboBox file at the same time using two properties, ID # and Name, that exist in the parent class.

The search box allows you to search for things from multiple source fields, but only in one dataset, not two different ones. And the search control only allows you to specify one search field to search for. Does anyone know how I can get the data from both datasets so that they appear together in a combo box?

+1


source to share


4 answers


Create your own TDBLookupComboBox that uses multiple data sources. ,, I used to create DB controls (specifically dropdown combo boxes). They are pretty easy to use and give you all the control you need.



+3


source


You can clone records from both datasets into a new dataset that contains the union of both.



+2


source


The answer to your original question that you linked to. You say that the members of both datasets have a common ancestor. So put all these object records in one TClientDataset, and then for your two descendant datasets, just use the cloned cursor from that underlying dataset on them. Thus, you can access them as separate sets or as a combined set of them.

Of course, rub ends up in any data that gets added to descent classes that don't share the base class, if you have any.

+1


source


Create a TDataSource, or a descendant of a TDataSet, which is actually a collection of other TDataSets. Then, when you insert, you either always insert into one specific TDataSet, or you have rules based on the value of a specific field that determines which TDataSet will be inserted.

0


source







All Articles