Page 1 of 1

TZAbstractDataset.InternalUpdate Error

Posted: 06.01.2011, 02:39
by DerekMcKinnon
Sometimes when I have made a change and then try to save it doesn't save.

The error seems to be in TZAbstractDataset.InternalUpdate on the line.
if (CachedResultSet <> nil) and GetActiveBuffer(RowBuffer) then

This is because CachedResultSet is nil.

I have found the trigger for this problem. In the TZQuery, I have the following code.
procedure TMainChild.QryInvAfterScroll(DataSet: TDataSet);
begin
if QryInv.FieldByName('Date').AsDateTime < stDate then
QryInv.ReadOnly := true
else
QryInv.ReadOnly := false;

end;

The problem occurs when I go to a record that sets the readonly value to true, and then go to a record where the readonly value is set to false. The screen works fine. When it is readonly, the user can't make any changes. When it is not readonly changes can be made.

However when the user tries to save, the CachedResultSet is nil and nothing is saved.

Posted: 13.01.2011, 21:44
by mdaems
DerekMcKinnon,
I don't think switching ReadOnly while the query is open is a good idea. Even worse, I sure someone should write the small patch that forbids it.

IF you want to work like that, make sure the query is updatable when you open it. Because it's at that time the decision is taken to make the resultset cached, I think. Otherwise you could also add a check that you only make the query updatable when the cachedresultset exists.

Mark