Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. RFX_Date throwing "Datetime field overflow" exception after changing to ODBC Driver 13 for SQL Server

RFX_Date throwing "Datetime field overflow" exception after changing to ODBC Driver 13 for SQL Server

Scheduled Pinned Locked Moved C / C++ / MFC
c++databasehelpannouncementhtml
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Member 11065933
    wrote on last edited by
    #1

    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).

    L D 3 Replies Last reply
    0
    • M Member 11065933

      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).

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Do you seriously need that precision for seconds?

      Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.

      1 Reply Last reply
      0
      • M Member 11065933

        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).

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • M Member 11065933

          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).

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Which RFX_Date are you using? Record Field Exchange Functions | Microsoft Docs[^].

          M 1 Reply Last reply
          0
          • L Lost User

            Which RFX_Date are you using? Record Field Exchange Functions | Microsoft Docs[^].

            M Offline
            M Offline
            Member 11065933
            wrote on last edited by
            #5

            good point, should have mentioned that, it's

            Quote:

            void AFXAPI RFX_Date(CFieldExchange* pFX, LPCTSTR szName, TIMESTAMP_STRUCT& value);

            L 1 Reply Last reply
            0
            • M Member 11065933

              good point, should have mentioned that, it's

              Quote:

              void AFXAPI RFX_Date(CFieldExchange* pFX, LPCTSTR szName, TIMESTAMP_STRUCT& value);

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Well, that really does not explain what is happening. Perhaps if you showed (in your original question) the actual code and the values that cause the problem ...

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups