Board index » delphi » URGENT Writing the contents of data-aware controls to the database TOUGH ONE

URGENT Writing the contents of data-aware controls to the database TOUGH ONE

Hi,
I have some data aware controls whose content is calculated with the value
of other  data aware components. When the user changes the value of one
component, the value of the others is recalculated. Everything works fine
until I do a Post command, then the content of the components changes to
some rubbish.

So the application calculates everything fine, but when I write it to the
database things go wrong.

Thanks in advance,
Coen De Roover

PS: please send a copy of your reply to cdero...@vub.ac.be

 

Re:URGENT Writing the contents of data-aware controls to the database TOUGH ONE


I need a little help here: What is doing the calculations? Is it the
underlying dataset? Is that a TTable or TQuery?
Cached updates?
Live query?

Have you used the de{*word*81} to step through you code to see if things
are when you expect them to?

Just a wild guess: maybe the recalculation uses some old values where
it should use new values.

Dan

On Sat, 3 Mar 2001 13:34:17 +0100, "Coen De Roover"

Quote
<cdero...@vub.ac.be> wrote:
>Hi,
>I have some data aware controls whose content is calculated with the value
>of other  data aware components. When the user changes the value of one
>component, the value of the others is recalculated. Everything works fine
>until I do a Post command, then the content of the components changes to
>some rubbish.

>So the application calculates everything fine, but when I write it to the
>database things go wrong.

>Thanks in advance,
>Coen De Roover

>PS: please send a copy of your reply to cdero...@vub.ac.be

--
Dan Brennand
CMDC systems, inc.
Configuration Management and Document Control:
visit us at www.cmdcsystems.com
[SPAM block: change at to @ in my e-mail address]

Re:URGENT Writing the contents of data-aware controls to the database TOUGH ONE


Hello :)

I had some trouble like that - just a hint -
look at the onEVENTs - maybe they will be triggered -
and 'go to work'
In my case I had to rewrite the 'onChange' event !

regards Kos

On Sat, 3 Mar 2001 13:34:17 +0100, "Coen De Roover"

Quote
<cdero...@vub.ac.be> wrote:
>Hi,
>I have some data aware controls whose content is calculated with the value
>of other  data aware components. When the user changes the value of one
>component, the value of the others is recalculated. Everything works fine
>until I do a Post command, then the content of the components changes to
>some rubbish.

>So the application calculates everything fine, but when I write it to the
>database things go wrong.

>Thanks in advance,
>Coen De Roover

>PS: please send a copy of your reply to cdero...@vub.ac.be

Re:URGENT Writing the contents of data-aware controls to the database TOUGH ONE


Coen

Without seeing your code I can't be very specific in my assistance.
However, in similar situations, I use memory variables rather than live
data.  Do the changes in a 'GetValues" and then save them in a "PutValues'
function that also checks for success.

Alan Jeffery
Professional Systems

"Coen De Roover" <cdero...@vub.ac.be> wrote in message
news:nk6o6.4284$yz3.151463@iguano.antw.online.be...

Quote
> Hi,
> I have some data aware controls whose content is calculated with the value
> of other  data aware components. When the user changes the value of one
> component, the value of the others is recalculated. Everything works fine
> until I do a Post command, then the content of the components changes to
> some rubbish.

> So the application calculates everything fine, but when I write it to the
> database things go wrong.

> Thanks in advance,
> Coen De Roover

> PS: please send a copy of your reply to cdero...@vub.ac.be

Re:URGENT Writing the contents of data-aware controls to the database TOUGH ONE


Thank you all for your replies, but I guess I'll have to be a bit more
specific:
Actually I'm doing nothing fancy.
I have some dbedit components on a form and I'm calculating the value of
some of them by using the .text property of some others. Everything goes
fine (the controls contain the right values), but when I do a post command
to the database, some values change.

Coen De Roover <cdero...@vub.ac.be> schreef in berichtnieuws
nk6o6.4284$yz3.151...@iguano.antw.online.be...

Quote
> Hi,
> I have some data aware controls whose content is calculated with the value
> of other  data aware components. When the user changes the value of one
> component, the value of the others is recalculated. Everything works fine
> until I do a Post command, then the content of the components changes to
> some rubbish.

> So the application calculates everything fine, but when I write it to the
> database things go wrong.

> Thanks in advance,
> Coen De Roover

> PS: please send a copy of your reply to cdero...@vub.ac.be

Re:URGENT Writing the contents of data-aware controls to the database TOUGH ONE


I mean I'm using the onchange events of the component to calculate the other
values

Coen

Re:URGENT Writing the contents of data-aware controls to the database TOUGH ONE


Quote
Coen wrote:

> I have some dbedit components on a form and I'm calculating the value of
> some of them by using the .text property of some others. Everything goes
> fine (the controls contain the right values), but when I do a post command
> to the database, some values change.

Yes, this is a bit tricky task, when the all the linked controls circumvent,
and everyone tries to update each others.

You'll just have to replace most of those TDbEdits with usual TEdits.
Use TDataSource's OnDataChange event to keep the right, updated values
on these TEdits.

Also use the OnExit events of both the TDbEdit and TEdit to update the
values in the other controls.

Plain TEdit control is very limited, not even having RightAlign property
for the text. You'll probably have to pick some free TEdit alternative
for it.

Markku Nevalainen

Re:URGENT Writing the contents of data-aware controls to the database TOUGH ONE


On Sun, 4 Mar 2001 14:14:58 +0100, "Coen"

Quote
<Coen.De.Roo...@village.uunet.be> wrote:
>I mean I'm using the onchange events of the component to calculate the other
>values

>Coen

Aha! This may be the smoking gun ;)
Even if you can figure out the exact order of calculations, it may be
too risky to use these events where there may be a problem to keep
things working as you develop your app. (see Markku's remarks today)

You might try something like turning RequestLive off in the TQuery,
and then use UpdateSQL to write the changes back to the DB. This will
allow you to do the calculations in a procedure, separate from the
database operations. It should be much easier to understand what's
going on sometime in the future when you need to maintain this code ;)

Dan

--
Dan Brennand
CMDC systems, inc.
Configuration Management and Document Control:
visit us at www.cmdcsystems.com
[SPAM block: change at to @ in my e-mail address]

Other Threads