Page 1 of 1

Trying to modify read-only field.

Posted: Tue 13 Mar 2007 14:27
by tulu
I have a client data set populated using a stored procedure. Then the client data set is modified by user, but not written back. All worked OK under BDE but, after I switched to CoreLab, I started to get the read-only field error.

Although I set the individual field as .readonly := false, I still get the "Trying to modify read-only field." error.

The field is a calcuated field. If I modify the stored procedure, first calculate the field and write into a temporary table, then return with a join all works fine. Something like this:

create procedure spTest
as begin
// age read only here.
select ID, Name, Age+1 as Age from testtable
end

go

create procedure spTest
as begin
// age can be modified here.
declare @a table (id int, age int null)
insert into @a(id, age)
select ID, Age+1 as Age from testtable

select T.ID, T.Name, A.Age as Age
from testtable T
JOIN @a A ON A.ID = T.ID

end

But as you can see, this is a lot of work, and sometimes not even feasible.
Any suggestions?

Posted: Tue 13 Mar 2007 20:03
by jfpicard
Try to add an empty TMSUpdateSQL connected to your query; it may solve the problem.

Posted: Wed 14 Mar 2007 08:19
by tulu
Thanks for the reply.

The thing works like this:

a qry -> a provider -> many client data sets.

I fill each client dataset using the same qry/provider pair. I connected an update sql to my query object. But did not work. Also I have tried to turn cached updates on. It still does not work.

Posted: Wed 14 Mar 2007 13:44
by Jackson
You should assign the SQLInsert, SQLUpdate, SQLDelete properties with the INSERT, UPDATE, DELETE statements correspondingly and set the TField.ReadOnly property to False in the DataSet fields editor for all the fields you want to update.

Posted: Wed 14 Mar 2007 15:25
by tulu
Thanks. Just fixing the fields did the trick.

I did not need the sqls or update object or cached updates = true.

Previously, I was trying to fix the readonly := false on clientdataset, in vain.
Now I fix them in the originating query, (afteropen event), and cds recieves them as readonly = false.

It works. :)