TUniquery Parameter text is different to value?

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
JoelH
Posts: 7
Joined: Thu 01 Apr 2010 10:48
Location: Germany

TUniquery Parameter text is different to value?

Post by JoelH » Mon 06 Jun 2016 08:24

I have a question about the text and value of a TUniqueryParameter.

I have the following code to fill the Parameter of a TUniquery:

Code: Select all

if (aFieldType in [ftDate,ftDateTime]) then
      begin
           Params.items[iParam].DataType := aFieldType;
           if (varisnull(Daten[icol, irow]))
           or (varisempty(Daten[icol,irow]))
           or (length(trim(vartostr(Daten[icol,irow]))) = 0) then
               Params.items[iparam].value := NULL
           else
               Params.items[iparam].Value := formatDateTime('dd.mm.yyyy hh:nn:ss',strtodatetime(Daten[icol,irow]));
in my case the Fieldtype is ftDateTime and the Value is set to (for today) '06.06.2016 00:00:00'

but if i let me show Params.items[iparam].text in the Debugger i receive '31.12.1899' .

My simple question, is why are text and value different?

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: TUniquery Parameter text is different to value?

Post by MaximG » Tue 07 Jun 2016 08:24

The '31.12.1899' value is correct in this case. You can make this sure using a simple code abstract :

Code: Select all

var
  myParam: TParam;
begin
  myParam := TParam.Create(Nil);
  try
    myParam.Value := Null;
    ShowMessage(myParam.Text);
    ShowMessage(DateTimeToStr(myParam.AsDateTime));
  finally
    myParam.Free;
  end;
end;

Post Reply