Trying to modify read-only field

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
kribo
Posts: 12
Joined: Thu 13 May 2010 15:51

Trying to modify read-only field

Post by kribo » Mon 31 May 2010 13:21

Hi, I have this SQL

Code: Select all

SELECT ID, SUM(AMOUNT) AS TOTAL
FROM TRANSACTIONS
GROUP BY ID
Previously I was using TClientDataset to execute above SQL statement and now, I'm trying with UniQuery, a DatasetProvier (linked to the UniQuery) and a ClientDataset (linked to DatasetProvider). The output is the same but I notice a strange behavior while trying to edit the TOTAL field, a 'Trying to modify read-only field.' That did not occur when I use TClientdataset alone and all fields were editable... Any clue???
FYI: I'm using version:2.70.0.9...

cxg417
Posts: 41
Joined: Thu 26 Mar 2009 08:07

Post by cxg417 » Mon 31 May 2010 13:35

FieldByName('TOTAL').Readonly:=False
________
Willys Jeep Wagon History
Last edited by cxg417 on Tue 15 Feb 2011 15:00, edited 1 time in total.

kribo
Posts: 12
Joined: Thu 13 May 2010 15:51

Post by kribo » Mon 31 May 2010 13:47

Hi, thanks for the suggestion. I did that already, no luck. But, if do on UniQuery level (with property ReadOnly=False) the fields are editable...
strange isn't it? is DatasetProvider the suspect?

bork
Devart Team
Posts: 649
Joined: Fri 12 Mar 2010 07:55

Post by bork » Tue 01 Jun 2010 08:50

Hello

You should set the SetFieldsReadOnly property of the TOraQuery component to True.

kribo
Posts: 12
Joined: Thu 13 May 2010 15:51

Post by kribo » Tue 01 Jun 2010 10:54

Hello Bork,
I tested your suggestion, still no effect. Well, I must inform here that finally I found a trick to solve it (fairly inefficient, I think):
1. Create persistent fields in the TUniQuery. I guess you already familiar with that (right-click on TUniQuery->Field editors->Add all fields)
2. Set ReadOnly property of Total field (was initially TRUE why?) to FALSE;
3. Skip DatasetProvider, nothing is needed to adjust....
4. Repeat steps 1 & 2 for TClientDataset (makes me cry :cry: )
By taking those steps, the existing process logic may continue with no modifications. With TClientdataset (alone), I can perform calculation and modifications on any fields contained in, even without doing step 1. Simply use FieldByName('fieldname').AsCurrency form. I'm really expecting what I've found is temporary, hoping you guys to find the best and simplest one. Thanks for the respond... ( :roll: waiting)

bork
Devart Team
Posts: 649
Joined: Fri 12 Mar 2010 07:55

Post by bork » Tue 01 Jun 2010 15:24

Try to perform the following steps:
1. Close ClientDataSet
2. Close OraQuery
3. Remove all fields that were created in the design mode from ClientDataSet
4. Remove all fields that were created in the design mode from OraQuery
5. Set the SetFieldsReadOnly property of the TOraQuery component to True
6. Open OraQuery
7. Open ClientDataSet
After performing these steps you will get the required result.

Fields that were created in the design mode with an old value of the SetFieldsReadOnly property will keep the old value of the ReadOnly property.

Also please specify what database and what DataProvider are you using.

kribo
Posts: 12
Joined: Thu 13 May 2010 15:51

Post by kribo » Wed 02 Jun 2010 04:35

Dear Bork,
I followed your steps and still it doesn't work out. I'm using UniDAC version 2.70.0.9. The components involved:
TSQLServerUniProvider
TUniConnection (conected to an SQL Server 2000)
TUniQuery
TDatasetProvider
TClientDataset
TDataSource
TDBGrid
Components not marked with bold-face are part of old design being migrated to UniDAC (here, minus TDCOMConnection). As I explained above they worked just fine before.

The reason we are migrating is due to Midas server setup, after XP SP2 release, raised so much headaches.

Anyhow, I must thank you for getting myself closer to the culprit :D. Instead of setting the SetFieldsReadOnly property, It seems to me that the ReadOnly property of TUniQuery was the problem. If I set it to FALSE the result fields become Read-Only*, conversely, the result fields become editable when its value is TRUE*. I think this is contrary to what commonly understood regarding its purpose. Also, I confuse with SetFieldsReadOnly what is its relation with TUniQuery.ReadOnly property.

Best regards,

*when accessed through ClientDataset

bork
Devart Team
Posts: 649
Joined: Fri 12 Mar 2010 07:55

Post by bork » Wed 02 Jun 2010 09:50

The SetFieldsReadOnly has influence on the ReadOnly property of TFields inside TUniQuery. If the SetFieldsReadOnly is set to True then not editable fields will have ReadOnly property set to True. But if SetFieldsReadOnly was set to False then the ReadOnly property of all fields will be set to False and all fields will be editable. The SetFieldsReadOnly property doesn't have any influence on the ReadOnly property of the TUniQuery component.

In UniDAC 2.70.0.9 a bug was found (and fixed in one of the next UniDAC versions), when all fields are editable if the ReadOnly property of the UniQuery componet is True. You should set the ReadOnly property to False and then the "ID" column will be editable and the "TOTAL" column will be read-only. If you want to have correct behavior of the UniQuery component with the ReadOnly property set to True then please download the latest version of the UniDAC component where this bug is fixed.

kribo
Posts: 12
Joined: Thu 13 May 2010 15:51

Post by kribo » Wed 02 Jun 2010 10:22

I'll do it right away, thanks for your support....

Jun 7, 2010:
Hmm what can I say, it still the same. I've tested with UniDAC version 3.00.0.9 for Delphi 7 Enterprise.
Its ok for now, as long as I can handle that...

Post Reply