AsDateTime wierd behaviour
I have a strange problem when trying to save a date in a database:
1. The following code is used to save some variables to a dbase
database:
procedure SaveClient(ClientTable:TTable; ClientName:String;
ClientDate:TDateTime; ClientCode:Double);
begin
try
ClientTable.FieldByName('Name').AsString := ClientName;
ClientTable.FieldByName('Date').AsDateTime := ClientDate;
ClientTable.FieldByName('Code').AsFloat := ClientCode;
...
except
On E:Exception do MessageDlg...
end;
end;
It is one of a number of database routines. When the module containing
them is a module in the delphi 1 project, all works well. WHen that
module is an external DLL (that obeys all the rules of BDE dlls as
given in DDevGuide), the ASDATETIME line compiles perfectly, but
causes a runtime GPF that is not passed to the exception handler. THe
other lines work just fine. The Date string is properly formatted.
THe identical code in a 32bit dll for Delphi 2 project compiles and
runs without error.
In the GET routine, the line
ClientDate :=DateToStr(ClientTable.FieldByName('Date').AsDateTime);
works.
I have noticed that 'AsDate' never seems to be recognised, even though
it is a function in the Delphi 1 reference. You have to use
AsDateTime. Also, The HELP recommends using VALUE instead of
ASDATETIME to set a value in a database, but the property is not
recognised ( it causes a 'field identifier expected' error in the
compiler.)
Does anyone know what's going on?
Rod.