Reading datetime2(3) from Microsoft SQL Server results in "Could not convert database value to object member"

When reading a datetime (datetime2(3) in Microsoft SQL Server) an exception is raised

"Exception = [Could not convert database value to object member. Class name: TDatabaseSAPProductActivate Column name: DT_ExpiryDate Attribute name: ExpiryDate Database value: 2020-12-31 00:00:00.000]"

This record is previously created with that entity component and that was without problems.

[Entity]
[Table('SAPProductActivate')]
[Id('FId', TIdGenerator.SmartGuid)]
TDatabaseSAPProductActivate = class
private
[Column('ID_SAPProductActivated', [TColumnProp.Required])]
FId : TGuid;
FStore : TDatabaseStore;
FDepartment : Integer;
FPLU : Integer;
FExpiryDate : TDateTime;
FProduct : TDatabaseProduct;
public
property ID : TGuid read FId write FId;

[Association([], [])]
[JoinColumn('ID_Store', [])]
property Store : TDatabaseStore read FStore write FStore;
[Column('UN_Department')]
property DepartmentNr     : Integer read FDepartment write FDepartment;
[Column('UN_PLU')]
property PLUNr     : Integer read FPLU write FPLU;
[Column('DT_ExpiryDate', [], 3)]
property ExpiryDate     : TDateTime read FExpiryDate write FExpiryDate;
[Association([], [])]
[JoinColumn('ID_Product', [])]
property Product : TDatabaseProduct read FProduct write FProduct;

end;

TMS Aurelius version 4.16 is used.

Which driver are you using? FireDAC? UniDAC? Native? Is it possible to provide a sample project that reproduces the problem?

Sorry for the late reaction (vacation)

Our application is using FireDAC and Microsoft SQL Server.
The problem occurs when we install our application on a clean Windows Server environment (SQL Server is on a separate box installed)
After installing "Installing SQL Server Native Client" on this server the problem does not occur anymore.

So, it seems it has to do with the SQLServer driver that FireDAC is using.

1 Like

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.