|
| Inconsistent behaviour of dBAware Components. |  
|
|---|
Product: Delphi all versions | Category: Database-VCL | Skill Level:
 | Scoring:  | Last Update: 07/28/2005 | Search Keys: delphi delphi3000 article borland vcl code-snippet Components dBAware Database | Times Scored: 3 | Visits: 2184 | Uploader: Hans Pieters Company: IHP Software France | Reference: N/A | | | Question/Problem/Abstract:
Inconsistent behaviour of dBAware Components. | Answer:
Assume:
a TAdoquery named aq_T and a
a TDatasource named dsaq_T with dataset set to aq_t.
a TDBEdit component named Ecom
with datafield aq_t.field1 ( a field like Amount )and a
a TDBRadiogroup component named Rcom
with datafield aq_t.field2 ( a field like Member Y/N)
All this on a form with two labels:
labelfield1 and labelfield2 and two buttons
a Button named BShow with
labelfield1.caption := aq_t.fieldbyname('field1').asstring;
labelfield2.caption := aq_t.fieldbyname('field2').asstring;
in the clickevent, and
a button name BPost with 'aq_t.post' in the clickevent.
Summary:
two dataentry fields,
a button to post and
two labels to look at the values in the table.
Experiment:
enter in Ecom 1000 and in Rcom Y - Press BPost - Press BShow
Result as expected : labelfield1 : 1000 labelfield2: Y
enter in Ecom 2000 and in Rcom N - Press BShow
Result not as expected : labelfield1 : 2000 labelfield2: Y <===
Conclusion:
when you enter data in a TdbEdit
the value of the table is updated at once
when you enter data in a TDBRadiogroup
the value of a table is not update unit the Post
That means that you can do something like
if aq_t.fieldbyname('field1').asfloat < 1000 then ....
but that you can NOT do something like
if aq_t.fieldbyname('field1').asstring = 'N' then ....
Of course you use the itemindex, but that is not the point.
The point that the behaviour is inconsistent.
For me this is and was the reason never to use dBaware components
for input. Moreover that is the only way to go in future.
|
|
|
| |
Sign up to consume product discounts for Bronze memberships !
|
|
| |
Community Ad of D. Wischnewski |
|
| |
|
|
|