Reported by Martijn Houtman; checked by Jordan Russell
There is a bug in Delphi 6.0, Build 6.136, SqlTimSt.pas. The function
function TryStrToSQLTimeStamp(const S: string; var TimeStamp: TSQLTimeStamp): Boolean;
var
DT: TDateTime;
begin
DT := StrToDateTime(S);
TimeStamp := DateTimeToSQLTimeStamp(DT);
Result := IsSqlTimeStampValid(TimeStamp);
end;
does not have the behaviour like it is described in the Help of Delphi 6.
Problem:
When the string S can not be converted to TSQLTimeStamp the result should be 'false' and TimeStamp = NullSqlTimeStamp. Instead of this an exception will be generated.
The function should be replaced with:
function TryStrToSQLTimeStamp(const S: string; var TimeStamp: TSQLTimeStamp): Boolean;
var
DT: TDateTime;
begin
Result := TryStrToDateTime(S, DT);
if Result then
begin
TimeStamp := DateTimeToSQLTimeStamp(DT);
Result := IsSqlTimeStampValid(TimeStamp);
end;
if not Result then
TimeStamp := NullSqlTimeStamp;
end;
This bug causes also an exception when passing a string in TClientDataSet.SetOptionalParameter, like for example:
TClientDataSet.SetOptionalParameter('TABLE_NAME', 'mytablename') |