Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread TDataset (TDatasource?) with multiple tables?
Thu, Aug 28 2008 5:02 PMPermanent Link

Rob
I need to display table data and allow editing in a DBGrid.  The trick is that I have the primary key values for the records that should be visible in
a memory table dataset (in the correct order) but want the DBGrid to display the data from the main database dataset.  Setting Mastersource on
the main dataset will create a relation, of course, but unless the grid is set to use the memeory dataset, I'll only see one record.  Adding lookup
fields on the memory dataset won't help because they can't be updated.

This seems so simple that I feel like I'm missing somethig obvious.  But it's looking like I'll need to create a TDataset descendent to handle this
specific case.  That seems like overkill.  Does anyone have any ideas?

Thanks,
-Rob
Thu, Aug 28 2008 5:05 PMPermanent Link

Sean
TDataset.OnFilterRecord will work, but it can be slow if there are a lot
of records.


Rob wrote:
> I need to display table data and allow editing in a DBGrid.  The trick is that I have the primary key values for the records that should be visible in
> a memory table dataset (in the correct order) but want the DBGrid to display the data from the main database dataset.  Setting Mastersource on
> the main dataset will create a relation, of course, but unless the grid is set to use the memeory dataset, I'll only see one record.  Adding lookup
> fields on the memory dataset won't help because they can't be updated.
>
> This seems so simple that I feel like I'm missing somethig obvious.  But it's looking like I'll need to create a TDataset descendent to handle this
> specific case.  That seems like overkill.  Does anyone have any ideas?
>
> Thanks,
> -Rob
>
Thu, Aug 28 2008 6:35 PMPermanent Link

Rob
Thanks, but the number of records was the main reason to resorting to a list of primary keys in a memory table.  I'm selecting a limited number
of 'current' records from a database with a lot of history using criteria not well suited to a single SQL query.

-Rob
Fri, Aug 29 2008 2:34 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Rob


I agree that DBISAM's OnFilterRecord could be a little faster Smileybut there's nothing wrong with its filter. Follow these steps:

1. obtain your set of primary IDs
2. Use that list to build a comma separated string
3. Build your filter - 'primaryid in (' + commaseparatedlist +')'
4. Set .Filtered = True

As long as the list isn't to big its fairly fast.

Roy Lambert [Team Elevate]
Fri, Aug 29 2008 6:40 AMPermanent Link

"John Hay"
Rob

> I need to display table data and allow editing in a DBGrid.  The trick is
that I have the primary key values for the records that should be visible in
> a memory table dataset (in the correct order) but want the DBGrid to
display the data from the main database dataset.  Setting Mastersource on
> the main dataset will create a relation, of course, but unless the grid is
set to use the memeory dataset, I'll only see one record.  Adding lookup
> fields on the memory dataset won't help because they can't be updated.
>
> This seems so simple that I feel like I'm missing somethig obvious.  But
it's looking like I'll need to create a TDataset descendent to handle this
> specific case.  That seems like overkill.  Does anyone have any ideas?

One option would be to to display and edit the memory table/query rather
than the actual database dataset.  You could then update the underlying
table in response to edits on the memory dataset.  This method has the
advantage that you will not get the "out to lunch" situation where a user
starts to edit a record and leaves it locked.

John

Fri, Aug 29 2008 1:25 PMPermanent Link

Rob
Thanks John, this is pretty much what I wound up doing.  I'm using a TJvDBUltimGrid which allows you to specify separate edit controls for each
column.  It doesn't seem to mind that these controls are not pointed to the underlying datasource of the grid, so it appears to be working pretty
well.

However, I'm still wishing for something like a TMultiDataset that would allow a datasource to be linked to master/detail tables.  It's frustrating to
be able to easily set these relations but not have the fields directly available in a grid.  I found something called TXQuery which seems to have
done this (as well as adding SQL access to non-SQL tables), but it doesn't appear to be available anymore.

-Rob
Image