 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Arjan de Haan Guest
|
Posted: Fri Feb 11, 2005 9:57 am Post subject: Using clones & updating the DB |
|
|
Hi.
I've got an application which has a single DataModule containing the datasets
(TADODataSet) to use. The application can display multiple forms which all present a
different view of some of these tables, so all forms get cloned datasets to avoid one form
inadvertently manipulating another form showing the same table.
The problem is how to update the database whenever one of these forms changes data or adds
a new record ?!
When I clone the dataset, the cloned set loses its connection and can't update the
database anymore. So I wrote for testing purposes a CopyRecord() function which copies the
changed data from a cloned set to the original (DB-connected) set and updates the database
through that. However the clones do NOT see the updated data! Not even after refreshing
the cloned set, or even the original set!
Anybody can shed some light on how to do this?? I really need the cloned sets because of
those multiple forms....
Tx.
Arjan
|
|
| Back to top |
|
 |
Del M Guest
|
Posted: Sat Feb 12, 2005 1:06 pm Post subject: Re: Using clones & updating the DB |
|
|
Right on ... those should be separate datasets. In object oriented
programming, "encapsulation" is an important principal and that means that a
form, which is a type of object, should own his own view of the data so that
any other form is free to do what it wants to do without having an effect on
another form.
|
|
| Back to top |
|
 |
Arjan de Haan Guest
|
Posted: Mon Feb 14, 2005 7:12 am Post subject: Re: Using clones & updating the DB |
|
|
"Del M" <Del.Murray (AT) CreditHawk (DOT) Net> wrote
| Quote: | Right on ... those should be separate datasets. In object oriented
programming, "encapsulation" is an important principal and that means that a
form, which is a type of object, should own his own view of the data so that
any other form is free to do what it wants to do without having an effect on
another form.
|
....which is roughly what you achieve using cloned datasets....except for saving to the
database part then ;-(
---
Arjan
|
|
| Back to top |
|
 |
Arjan de Haan Guest
|
Posted: Mon Feb 14, 2005 7:13 am Post subject: Re: Using clones & updating the DB |
|
|
"Brian Bushay TeamB" <BBushay (AT) Nmpls (DOT) com> wrote
| Quote: |
I've got an application which has a single DataModule containing the datasets
(TADODataSet) to use. The application can display multiple forms which all present a
different view of some of these tables, so all forms get cloned datasets to avoid one
form
inadvertently manipulating another form showing the same table.
The problem is how to update the database whenever one of these forms changes data or
adds
a new record ?!
I don't understand what you are trying to accomplish here. Seems to me you a
separate query for each form and do a Requery when you need to refresh the data
in any of the forms.
|
What I wanted to achieve was not constantly having to requery the database on each change
the user makes.
Some background info:
One of the forms is used to enter 'templates' for (sort of) orders. A user can create a
template order consisting of the order data itself and any number of order detail lines.
In another form these templates can be selected to create a new order. All data from the
template (including the order detail lines) are then added to an in-memory dataset which
the user can edit as he/she pleases. When done, the entire order is saved to the database.
The templates are used to avoid superfluous typing and be able to quickly generate a new
order. This is for a production facility (so 'orders' might not be the proper description
here but it serves its goal).
I thought since I already have the template dataset loaded, reuse a cloned instance in
other forms. This way I don't have to have multiple datasets which all point to the same
table, and they can't influence one another.
Think again I guess....
Tx.
....Arjan...
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|