Please send a project reproducing the issue. We really can't guess what is going on.
The error message indicates you are dealing with some null data, but if you can't debug there to check if some of the fields you are dealing with are null or not, we need a sample project.
the problem is the state edit or insert of dataset. in fact if i use
If Dataset.State In [dsEdit,dsInsert] Then Begin
DataSet.FieldByName('Data_Asp').AsDateTime:=DataSet.FieldByName('Data_Ora_Asp').AsDateTime;
DataSet.FieldByName('Ora_Asp').AsDateTime:=DataSet.FieldByName('Data_Ora_Asp').AsDateTime;
End;
go fine when i insert a new rec but after i cant have a values of that fields.
See this code : in aftrer open of dataset i decide to insert a new record and i think the error happen when dataset "opening" before fire after open event !!
See the end of code : I tryed to attach the wdTOrd.OnCalcFields:=wdTOrdCalcFields; BUT error happen always... THEN i think this happen during open dataset.
procedure TDM0.wdTOrdAfterOpen(DataSet: TDataSet);
Var QryCli:String;
DataResponse:TXDataClientResponse;
ResData:TaStrings;
begin
If orOper = orNEW Then Begin
DataSet.Insert(); // vedi anche wdTOrdNewRecord
....
End;
If orOper = orMOD Then Begin
wdROrd.Close();
wdROrd.QueryString:=Format('$filter=(PK_1 eq %d)&$orderby=Pos_Rigo',[DataSet.FieldByName('PK_1').AsInteger]);
wdROrd.Load(); // fire : wdROrdAfterOpen
End;
wdTOrd.OnCalcFields:=wdTOrdCalcFields;
end;
I've always problem with calcfields when i edit record ...
Attached sample : when start main try to edit the phone number 999-9999 and see fields below that hide , these are calcfields !! Ristord.zip (3.1 MB)
NOTE : archive is .RAR type
// -----------------------------------------------------------------------------
// NB : se c'è un SetJsonData('{}'); il calfields dà problemi di assegnazione valori null
// in realtà si tratta di una questione di wdTOrd.State(dsEdit, dsInsert)
procedure TDM0.wdTOrdCalcFields(DataSet: TDataSet);
begin
DataSet.FieldByName('Data_Asp').AsDateTime:=DataSet.FieldByName('Data_Ora_Asp').AsDateTime;
DataSet.FieldByName('Ora_Asp').AsDateTime:=DataSet.FieldByName('Data_Ora_Asp').AsDateTime;
end;
You are calling DM0.wdTOrd.Post in WebFormCreate, thus the dataset is not in edit mode anymore. If you want to keep editing it, you should keep the record in edit mode.