BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Error with TFieldDataLink: EStackoverflow

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Writing
View previous topic :: View next topic  
Author Message
Renato A. Martins
Guest





PostPosted: Tue Oct 07, 2003 11:59 am    Post subject: Error with TFieldDataLink: EStackoverflow Reply with quote



Hi, I am with a problem, when i insert a new record in the dataset, he
return a error menssage in procedure:

procedure TMySqlCheckBox.OnDataChange(Sender: TObject);
begin
if FDataLink.Field.IsNull then
checked:=false
else
checked:=true;
end;

the procedure run normaly, but when i insert a new record, he return the
menssage "Stack overflow".


Back to top
Robert Cerny
Guest





PostPosted: Tue Oct 07, 2003 11:27 pm    Post subject: Re: Error with TFieldDataLink: EStackoverflow Reply with quote



Setting Checked property somehow re-triggers OnDataChange.

--
Robert Cerny
DelphiShaman
"Renato A. Martins" <renato (AT) inoutnet (DOT) com.br> wrote

Quote:
Hi, I am with a problem, when i insert a new record in the dataset, he
return a error menssage in procedure:

procedure TMySqlCheckBox.OnDataChange(Sender: TObject);
begin
if FDataLink.Field.IsNull then
checked:=false
else
checked:=true;
end;

the procedure run normaly, but when i insert a new record, he return the
menssage "Stack overflow".





Back to top
Renato A. Martins
Guest





PostPosted: Mon Oct 13, 2003 2:44 pm    Post subject: Re: Error with TFieldDataLink: EStackoverflow Reply with quote



But this component is have the ancestor Tcheckbox and not TDBcheckbox. The
event OnDataChange is create for me. look the resumed code:



type
TMySqlCheckBox = class(TCheckBox)

constructor TMySqlCheckBox.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FDataLink := TFieldDataLink.Create;
FDataLink.OnDataChange := OnDataChange;
end;

procedure TMySqlCheckBox.OnDataChange(Sender: TObject);
begin
if FDataLink.Field.IsNull then
checked:=false
else
checked:=true;
end;

procedure TMySqlCheckBox.Click;
begin
if (datasource.dataset.state=dsinsert) or
(datasource.dataset.state=dsedit) then
begin
if datasource.dataset.fieldbyname(datafield).asstring='X' then
datasource.dataset.fieldbyname(datafield).asstring:=''
else
datasource.dataset.fieldbyname(datafield).asstring:='X';
end
else
begin
if datasource.dataset.fieldbyname(datafield).asstring='X' then
checked:=true
else
checked:=false;
end;
end;









----- Original Message -----
From: "Robert Cerny" <robert.qwe.cerny (AT) neosys (DOT) xrs.qwe.si>
Newsgroups: borland.public.delphi.vcl.components.writing
Sent: Tuesday, October 07, 2003 8:27 PM
Subject: Re: Error with TFieldDataLink: EStackoverflow


Quote:
Setting Checked property somehow re-triggers OnDataChange.

--
Robert Cerny
DelphiShaman
"Renato A. Martins" <renato (AT) inoutnet (DOT) com.br> wrote in message
news:3f82aa6a (AT) newsgroups (DOT) borland.com...





Back to top
Robert Cerny
Guest





PostPosted: Tue Oct 14, 2003 12:53 pm    Post subject: Re: Error with TFieldDataLink: EStackoverflow Reply with quote

If you want to reinvent the wheel, do it properly.

Also:
..asstring:='' sets is to empty string, while OnDataChange checks for
..IsNull.
--
Robert Cerny
DelphiShaman

"Renato A. Martins" <renato (AT) inoutnet (DOT) com.br> wrote

Quote:
But this component is have the ancestor Tcheckbox and not TDBcheckbox. The
event OnDataChange is create for me. look the resumed code:



type
TMySqlCheckBox = class(TCheckBox)

constructor TMySqlCheckBox.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FDataLink := TFieldDataLink.Create;
FDataLink.OnDataChange := OnDataChange;
end;

procedure TMySqlCheckBox.OnDataChange(Sender: TObject);
begin
if FDataLink.Field.IsNull then
checked:=false
else
checked:=true;
end;

procedure TMySqlCheckBox.Click;
begin
if (datasource.dataset.state=dsinsert) or
(datasource.dataset.state=dsedit) then
begin
if datasource.dataset.fieldbyname(datafield).asstring='X' then
datasource.dataset.fieldbyname(datafield).asstring:=''
else
datasource.dataset.fieldbyname(datafield).asstring:='X';
end
else
begin
if datasource.dataset.fieldbyname(datafield).asstring='X' then
checked:=true
else
checked:=false;
end;
end;




Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Writing All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.