RFX_Date throwing "Datetime field overflow" exception after changing to ODBC Driver 13 for SQL Server
-
Hi, MFC app using CRecordset to transfer data to a SQL Server database. Uses the RFX_Date mechanism mapping to SQL Server "datetime" data types, previously using the old "SQL Server" odbc driver and all was well. Trying to update to the more recent "ODBC Driver 13 for SQL Server" (TLS 1.2 support) and when attempting to write to the SQL Database I'm seeing the following exception :- "Datetime field overflow. Fractional second precision exceeds the scale specified in the parameter binding." Have found the following article which identifies the issue as related to the updated drivers (since SQL Server 2008) being unable to infer the precision of the parameter if not explictly detailed so throws the exception. I tried changing the datatype on the Server to datetime2 with various precisions e.g. datetime2(0), datetime2(3) and datetime2(7), none of which worked. I have subsequently read (here) that this issue cannot be resolved by server sides changes and is a breaking change for older clients :-< It states there that
Quote:
I think the application change is just a matter of specifying a scale of 3.
I'm not sure what that means in terms of using the RFX_Date approach, will I have to write an RFX_Date2 replacement or is there one out here already? If anyone has had a similar issue I'd appreciate hearing their suggestions on how to resolve this (preferably without having to do an update to the client app if possible).
-
Hi, MFC app using CRecordset to transfer data to a SQL Server database. Uses the RFX_Date mechanism mapping to SQL Server "datetime" data types, previously using the old "SQL Server" odbc driver and all was well. Trying to update to the more recent "ODBC Driver 13 for SQL Server" (TLS 1.2 support) and when attempting to write to the SQL Database I'm seeing the following exception :- "Datetime field overflow. Fractional second precision exceeds the scale specified in the parameter binding." Have found the following article which identifies the issue as related to the updated drivers (since SQL Server 2008) being unable to infer the precision of the parameter if not explictly detailed so throws the exception. I tried changing the datatype on the Server to datetime2 with various precisions e.g. datetime2(0), datetime2(3) and datetime2(7), none of which worked. I have subsequently read (here) that this issue cannot be resolved by server sides changes and is a breaking change for older clients :-< It states there that
Quote:
I think the application change is just a matter of specifying a scale of 3.
I'm not sure what that means in terms of using the RFX_Date approach, will I have to write an RFX_Date2 replacement or is there one out here already? If anyone has had a similar issue I'd appreciate hearing their suggestions on how to resolve this (preferably without having to do an update to the client app if possible).
-
Hi, MFC app using CRecordset to transfer data to a SQL Server database. Uses the RFX_Date mechanism mapping to SQL Server "datetime" data types, previously using the old "SQL Server" odbc driver and all was well. Trying to update to the more recent "ODBC Driver 13 for SQL Server" (TLS 1.2 support) and when attempting to write to the SQL Database I'm seeing the following exception :- "Datetime field overflow. Fractional second precision exceeds the scale specified in the parameter binding." Have found the following article which identifies the issue as related to the updated drivers (since SQL Server 2008) being unable to infer the precision of the parameter if not explictly detailed so throws the exception. I tried changing the datatype on the Server to datetime2 with various precisions e.g. datetime2(0), datetime2(3) and datetime2(7), none of which worked. I have subsequently read (here) that this issue cannot be resolved by server sides changes and is a breaking change for older clients :-< It states there that
Quote:
I think the application change is just a matter of specifying a scale of 3.
I'm not sure what that means in terms of using the RFX_Date approach, will I have to write an RFX_Date2 replacement or is there one out here already? If anyone has had a similar issue I'd appreciate hearing their suggestions on how to resolve this (preferably without having to do an update to the client app if possible).
Can you split the seconds field, which is currently some floating-point type, up into two integer fields, one for seconds and the other for fractions of a second?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
Hi, MFC app using CRecordset to transfer data to a SQL Server database. Uses the RFX_Date mechanism mapping to SQL Server "datetime" data types, previously using the old "SQL Server" odbc driver and all was well. Trying to update to the more recent "ODBC Driver 13 for SQL Server" (TLS 1.2 support) and when attempting to write to the SQL Database I'm seeing the following exception :- "Datetime field overflow. Fractional second precision exceeds the scale specified in the parameter binding." Have found the following article which identifies the issue as related to the updated drivers (since SQL Server 2008) being unable to infer the precision of the parameter if not explictly detailed so throws the exception. I tried changing the datatype on the Server to datetime2 with various precisions e.g. datetime2(0), datetime2(3) and datetime2(7), none of which worked. I have subsequently read (here) that this issue cannot be resolved by server sides changes and is a breaking change for older clients :-< It states there that
Quote:
I think the application change is just a matter of specifying a scale of 3.
I'm not sure what that means in terms of using the RFX_Date approach, will I have to write an RFX_Date2 replacement or is there one out here already? If anyone has had a similar issue I'd appreciate hearing their suggestions on how to resolve this (preferably without having to do an update to the client app if possible).
-
Which RFX_Date are you using? Record Field Exchange Functions | Microsoft Docs[^].
good point, should have mentioned that, it's
Quote:
void AFXAPI RFX_Date(CFieldExchange* pFX, LPCTSTR szName, TIMESTAMP_STRUCT& value);
-
good point, should have mentioned that, it's
Quote:
void AFXAPI RFX_Date(CFieldExchange* pFX, LPCTSTR szName, TIMESTAMP_STRUCT& value);