Last post Jul 19, 2016 06:23 PM by march11
Jul 15, 2016 08:53 AM|PhC|LINK
When I change ODBC to use SQL Server Native Client 11, not use SQL Server, I find an error "Datetime field overflow" is thrown.
The database is SQL 2005 and will upgrade to SQL 2012 or above soon, the datetime field type is "DateTime".
I find that it only throws datetime errors when system uses ODBC to pass datetime (e.g. DateTime.Now). Is there any method to solve this problem?
Jul 15, 2016 06:12 PM|march11|LINK
You probably need to check the type coming from ODBC, its more than likely a string. You should be able to CAST it into a DateTime type.
Jul 16, 2016 08:53 AM|Chris Zhao|LINK
I find an error "Datetime field overflow" is thrown.
This error occurs when you try to write a date that is outside the valid range of dates for the Microsoft SQL Server datetime field. To correct the error, make sure you are using a date within valid range.
Take a look at Updating an Application from SQL Server 2005 Native Client. This topic discusses the breaking changes in SQL Server Native Client since SQL Server Native Client in SQL Server
Jul 18, 2016 12:48 AM|PhC|LINK
After further checking, I find following error:
Datetime field overflow. Fractional second precision exceeds the scale specified in the parameter binding.
The input value is DATETIME.Now, the value is valid. How can I solve this problem?
Jul 18, 2016 01:31 PM|march11|LINK
I think the type you are using will not support the detail, sometimes when the time as milliseconds this conversion will occur. You need to format the time then cast into your .net variable.
Take a look at these since you have not posted the actual time values I can not help with which format to use.
Jul 19, 2016 08:31 AM|PhC|LINK
Lastly, I set the odbc parameter scaler to 3. And it works. Thanks for your help.
Jul 19, 2016 06:23 PM|march11|LINK
Glad we could help, how about an up vote?