Hello Gyse,
i have an database table "employee" and associated table "servicetime".
If I've added a new employee to the database but haven't yet recorded any service hours for that employee, I get an exception when I view the employee.
As soon as I have insert service hours for the employee, I don't get an exception anymore.
What am I doing wrong? The code is "very identical" to the example in the Aurelius manual page 208.
a short code-snip:
employees:=FManager.Find<Tapp_Employee>.OrderBy('emp_lastname').List;
if employees.Count>0 then
try
adsEmployee.SetSourceList(employees);
adsEmployee.Open;
if (not adsEmployee.FieldByName('emp_servicetime').IsNull) then
begin
try adsServicetime.DatasetField:=(adsEmployee.FieldByName('emp_servicetime') as TDatasetField); // <-- here I get the exception. If no service hours have been recorded for the employee
adsServicetime.Open;
sgServicetime.Visible:=(adsServicetime.RecordCount>0);
finally
end;
end;
....
In addition to what @Ferrari_Julio said, could you also provide the call stack at the moment of the error, and provide the persistent fields defined in the datasets - or are they created dynamically?
What is really interesting is that the error ONLY appears when no records are stored in "servicetime". As soon as I insert a record, everything is okay.
Could you please paste it again and use the Preformatted text feature ( the </> toolbar button ) ?
All your Nullable type declarations went invisible, as they were interpreted as HTML tags.
Please paste Create and Destroy procedures.
And don't forget what @wlandgraf asked:
could you also provide the call stack at the moment of the error, and provide the persistent fields defined in the datasets - or are they created dynamically?
(Noticed you're using overload instead of override with Create and Destroy)