Page 1 of 1

LargeInt Fields

Posted: Mon 21 Feb 2011 17:52
by adoniram
After update unidac to 3.60.0.15 version we cannot access LargeInt field with Value property. Instead we have to do AsInteger to work.

If we use Table.FieldByName('LargeIntField').Value it raises "Cannot access field 'LargeIntField' as type Variant" error.

On prior version (3.0.0.9) it's not happened.

Posted: Tue 22 Feb 2011 08:27
by AlexP
Hello,

Please specify the name of your database.

Posted: Thu 24 Feb 2011 16:50
by adoniram
SQL Server.

Posted: Fri 25 Feb 2011 08:19
by AndreyZ
This error raises by the TLargeintField class and it depends only on the Delphi version you are using. Starting with Delphi 2005 you won't get such error.

Posted: Fri 25 Feb 2011 17:40
by adoniram
But before unidac update it works.
Why?

Posted: Mon 28 Feb 2011 13:16
by AndreyZ
If you don't use persistent fields, you should use the following code:

Code: Select all

TLargeintField(Table.FieldByName('LargeIntField')).Value
In this way you determine that Delphi must use the TLargeintField.Value property that is defined in the following way:

Code: Select all

property Value: Largeint read GetAsLargeint write SetAsLargeint;
In this case there will be no error. If you don't do this, Delphi will invoke the TField.SetAsVariant method, and this method will invoke the TLargeintField.SetVarValue method that is defined in the following way:

Code: Select all

procedure TLargeintField.SetVarValue(const Value: Variant);
begin
  raise AccessError('Variant'); // here this error is raised
end;
If you use persistent fields, you should use the following code:

Code: Select all

TableLargeIntField.Value
In this case the TLargeintField.SetAsLargeint will be invoked and there will be no error.

Posted: Tue 01 Mar 2011 18:07
by adoniram
Ok,
Thanks!.

Posted: Wed 02 Mar 2011 07:59
by AndreyZ
Feel free to contact us if you have any further questions about UniDAC.