Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
245
DataBinding & UltraTimeSpanEditor
posted

I am trying to bind an UltraTimeSpanEditor to a Time field in an SQL Server 2008 database.

However, when I try and update the value (1 day)  from the control to the database I get the following error:

"SqlDbType.Time overflow.  Value '1.00:00:00' is out of range.  Must be between 00:00:00.0000000 and 23:59:59.9999999."

Is it not possible to bind the control like this? Otherwise is there some other SQL Server field that i can bind to?

Thanks!

Parents
No Data
Reply
  • 53790
    posted

    Hi,

    In your issue you need to map Microsoft SQL Server 2008 data type Time(7) or TimeSpan:time(7) and  .NET Framework 3.5 SP1 System.TimeSpan. However, there is a large difference between the range that the CLR System.TimeSpan supports and what the SQL Server TIME type supports. Mapping values less than 0 or greater than 23:59:59.9999999 hours to the SQL TIME will result in overflow exceptions. For more details you could take a look at : http://msdn.microsoft.com/en-us/library/bb386947.aspx

    Our UltraTimeSpanEditor use data type TimeSpan which has one additional “place” for days - 0.00:00:00.0000000. If you want to bind the field, before storing/reading the data in the database you would need to take care for the Days “place” and store/read this additional information in/from separate a column (for example: columns Days – type int). 

    Maybe one other approach is to use SQL  data type “nvarchar” . By this way you need to convert your TimeSpan  value to string and back to TimeSpan.

    Please if you have any questions do not hesitate to ask me

    Regards

Children
No Data