delphi3000.com - the free delphi knowledge platform
delphi3000.com - the free delphi knowledge platform
Have a look at your member-status

connecting people's knowledge


  - Recent ArticlesRSS feed for Recent Articles on delphi3000.com
  - List of All Articles
  - Top Viewed Articles
  - Articles (+Attachem.)
  - Articles Of Interest
  - Categories
  - Top Uploader
  - Search
  - Index

  - My Home
  - Submit an Article
  - My Articles
  - My Personal Data
  - My Bookmarks
  - Activities
  - Login/Logout

  - Sign Up
  - Why Sign Up
  - Newsletter

  - Press
  - Advertise

  - Contact
  - Feedback



Community
Borland
ClubeDelphi
Dr. Bob
UK-BUG
Delphi Meetings
Planeta Delphi








Share this article with friendsShare this article with friends
Rate this articleRate this article - to keep the quality of delphi3000.com !
Comment this article or read through previous comments (2)


Inconsistent behaviour of dBAware Components.Go to Hans Pieters's websiteFormat this article printer-friendly!Bookmark function is only available for registered users!
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.







Please rate this article!
Skill level:
BeginnerExpert

Useful:
No!Very!

Overall rating:
PoorExcellent



Comments to this article
Write a new comment
you mean the .value?
    Eber Irigoyen (Jul 28 2005 7:56PM)

if you just wanted to compare against the value, you coul've just used the .value property, all the other ones are just helpers to make life easier
Respond

RE: you mean the .value?
Hans Pieters (Jul 28 2005 8:58PM)

If you have a dataentry screen with a postbutton, you cannot use - in the click event of that Postbutton - the fieldvalue of the field covered by the TDBRadiogroup as you can for the amount (in my example) covered by the TDBEdit.  

if aq_t.fieldbyname('field1').asstring = 'N'  then
begin
your code
end;

will produce wrong results because field1 (covered by the TDBRadiogroup) has not been changed yet.

Of course you can use .value or work with the itemindex, but that is not my point.
It is inconsistent and will eventually produce wrong results.
Respond














 
Sign up to consume product discounts for Bronze memberships !

read more


   


  Community Ad of
D. Wischnewski
 
   














 







     
  Copyright © 2000 - 2007 delphi3000.com - All rights reserved. Terms of use. || Privacy
delphi3000.com is a service by bluestep.com IT-Services GmbH (Vienna)