TvirtualQuery + TTable - two important errors
Posted: Sun 26 May 2019 18:02
Hi
My environment: Windows 10, Delphi 10.3 Update 1, UniDac 7.4.12
Object TTable open with table Dbase 7 "Example.dbf" (important level 7) created by BDE.
Table "Example" has 2 fields: "ID" - AutoIncrement and "Name" - String
TTable (named "T1") is connected with TVirtualQuery (named "VQ").
VQ.SQL.Text := SELECT * FROM T1
VQ.KeyFields := ID
Error 1:
We open whole and across Grid we change content of field "Name".
We receive error (translation from Polish): "Field ID cannot be modified".
Error is result of property "ReadOnly" of field T1.ID However field T1.ID is not modified.
( viewing with DBmonitor: UPDATE main.T1 SET NAME = ? WHERE ID = ? )
This error can be avoided through use of following sequence of code:
T1.Active := TRUE;
T1.FieldByName('ID').ReadOnly := FALSE;
VQ.Active := TRUE;
However such solution is only prosthesis.
Error 2 (FATAL !):
We open whole and across Grid we clean content of field "Name" and we close whole.
Again we open whole and receive error (translation from Polish):
"Cannot make conversion variant of type (NULL) on type "(OleStr)"
I suppose that error can result from way of filling of empty StringField in Dbase 7 (bytes zero).
Regards
My environment: Windows 10, Delphi 10.3 Update 1, UniDac 7.4.12
Object TTable open with table Dbase 7 "Example.dbf" (important level 7) created by BDE.
Table "Example" has 2 fields: "ID" - AutoIncrement and "Name" - String
TTable (named "T1") is connected with TVirtualQuery (named "VQ").
VQ.SQL.Text := SELECT * FROM T1
VQ.KeyFields := ID
Error 1:
We open whole and across Grid we change content of field "Name".
We receive error (translation from Polish): "Field ID cannot be modified".
Error is result of property "ReadOnly" of field T1.ID However field T1.ID is not modified.
( viewing with DBmonitor: UPDATE main.T1 SET NAME = ? WHERE ID = ? )
This error can be avoided through use of following sequence of code:
T1.Active := TRUE;
T1.FieldByName('ID').ReadOnly := FALSE;
VQ.Active := TRUE;
However such solution is only prosthesis.
Error 2 (FATAL !):
We open whole and across Grid we clean content of field "Name" and we close whole.
Again we open whole and receive error (translation from Polish):
"Cannot make conversion variant of type (NULL) on type "(OleStr)"
I suppose that error can result from way of filling of empty StringField in Dbase 7 (bytes zero).
Regards