Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 8 of 8 total
Thread Broadcast Dataset change to data controls
Mon, Sep 19 2022 4:37 PMPermanent Link

Eivind

Gents,

I just updated to 3.02 B7 and part of my app stoped working the way they where designed and worked in previous versions. My core issue is when in code setting a value for a dataset columns it does to broadcast changes to its data aware controls. Or actually, it does so only the first time data is changed in code. Take this example where a DataSet1 is connected to a grid and an edit control for example. I have two buttons with the following code:

procedure TForm1.Button1Click(Sender: TObject);
begin
if DataSet1.State = dsBrowse then
  DataSet1.Update;
  DataSet1.Columns['COL1'].AsString := 'AAAAA';
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
if DataSet1.State = dsBrowse then
  DataSet1.Update;
  DataSet1.Columns['COL1'].AsString := 'BBBBB';
end;

Once Button1 is clicked the data in the grid and edit control changes to 'AAAAA'. However, when clicking the Button 2 no changes can be seen. HOWEVER, after clicking the Button2 I have a third button with: ShowMessage(DataSet1.Columns['COL1'].AsString). The data in the dataset is changed as the ShowMessage will show 'BBBBB' but the data showed in the grid and edit control still show 'AAAAA'. The changes is never broadcasted to its controls.

I'm pretty sure this has changed since the previous versions of 3.02. After playing around a bit I found that if I had DataSet1.Save as the last line in the Button1 and Button2 code it does change the value of the data aware controls every time.

Is this as designed? Should you not be able to change values in a dataset and have it broadcasted to its control more than one time?

This creates some issues for me as I have som custom made ComboBoxes that the user can select a value and it written to its dataset. So if the user now selects one value and later decides to select another one the last selection is not seen until the .Save is called for the dataset.

Would love to hear if you guys have seen this as-well and I'm supposed to call DataSet.Save every-time I do some changes to a column in a dataset.

Cheers

Eivind
Tue, Sep 20 2022 6:40 AMPermanent Link

Walter Matte

Tactical Business Corporation

I just tested and confirm this is a bug....

 Users.Update;
 Users.Columns['FirstName'].asString := 'AAA';
 Users.Columns['FirstName'].asString := 'BBB';


Only AAA appears....

If I do a Users.Save;  then 'BBB' Apears.

Please report the Incident so it can be fixed.....

Walter


Eivind wrote:

Gents,

I just updated to 3.02 B7 and part of my app stoped working the way they where designed and worked in previous versions. My core issue is when in code setting a value for a dataset columns it does to broadcast changes to its data aware controls. Or actually, it does so only the first time data is changed in code. Take this example where a DataSet1 is connected to a grid and an edit control for example. I have two buttons with the following code:

procedure TForm1.Button1Click(Sender: TObject);
begin
if DataSet1.State = dsBrowse then
  DataSet1.Update;
  DataSet1.Columns['COL1'].AsString := 'AAAAA';
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
if DataSet1.State = dsBrowse then
  DataSet1.Update;
  DataSet1.Columns['COL1'].AsString := 'BBBBB';
end;

Once Button1 is clicked the data in the grid and edit control changes to 'AAAAA'. However, when clicking the Button 2 no changes can be seen. HOWEVER, after clicking the Button2 I have a third button with: ShowMessage(DataSet1.Columns['COL1'].AsString). The data in the dataset is changed as the ShowMessage will show 'BBBBB' but the data showed in the grid and edit control still show 'AAAAA'. The changes is never broadcasted to its controls.

I'm pretty sure this has changed since the previous versions of 3.02. After playing around a bit I found that if I had DataSet1.Save as the last line in the Button1 and Button2 code it does change the value of the data aware controls every time.

Is this as designed? Should you not be able to change values in a dataset and have it broadcasted to its control more than one time?

This creates some issues for me as I have som custom made ComboBoxes that the user can select a value and it written to its dataset. So if the user now selects one value and later decides to select another one the last selection is not seen until the .Save is called for the dataset.

Would love to hear if you guys have seen this as-well and I'm supposed to call DataSet.Save every-time I do some changes to a column in a dataset.

Cheers

Eivind
Tue, Sep 20 2022 6:48 AMPermanent Link

Walter Matte

Tactical Business Corporation

This issue has gone unnoticed .... I tested 3.02 B6 and the same issue / bug - exists.....

Walter
Tue, Sep 20 2022 6:51 AMPermanent Link

Walter Matte

Tactical Business Corporation

This has been here a long time.... 3.01B4 has the same problem.

Walter
Tue, Sep 20 2022 3:14 PMPermanent Link

Eivind

Walter Matte wrote:
This has been here a long time.... 3.01B4 has the same problem.

Wow. Thanks for confirming Walter. I submitted an Incident report and got a feedback from Tim that he will look into it and incorporate a fix in the next release coming out shortly.
Tue, Sep 20 2022 4:51 PMPermanent Link

erickengelke

Avatar

Eivind wrote:
>I just updated to 3.02 B7 and part of my app stoped working the way they where designed and worked in previous versions.

I thought you had to dataset1.save afterwards.

Erick
EWB Programming Books and Component Library
http://www.erickengelke.com
Wed, Sep 21 2022 6:37 AMPermanent Link

Walter Matte

Tactical Business Corporation

Yes you will ultimately Save.   

But you might be setting a Status for example during the course of the life of a Form.... example Camp Registration site with EWB and as items are filled our a field indicates what stage they are at in the progress of entering and this is save in the db table.... but as they progress it is updated and only saved when they say they are done.....

Reg.Update;
Reg.Columns['Step'].AsString := 'Enter Family Info';

Reg.Columns['Step'].AsString := 'Enter Camper Info';

Reg.Columns['Step'].AsString := 'Enter Payment Info';

......

This is a hypothetical example but it happens often....at least I have done this kind of thing with error status, timesheet entry,....

Walter



erickengelke wrote:

Eivind wrote:
>I just updated to 3.02 B7 and part of my app stoped working the way they where designed and worked in previous versions.

I thought you had to dataset1.save afterwards.

Erick
EWB Programming Books and Component Library
http://www.erickengelke.com
Mon, Oct 24 2022 4:34 AMPermanent Link

Richard Harding

Wise Nutrition Coaching

<<This issue has gone unnoticed .... I tested 3.02 B6 and the same issue / bug - exists.....>>

I noticed it some time ago - I cannot find when and where. I probably did not describe it very well.

Richard
Image