none
"An overflow occurred while converting to datetime." Error?

    Question


  • I am using SQLCE for a backend database for a desktop application.  I have a data entry form which is using a DateTimePicker control that is bound to a Date field in my table.  It defaults to Todays date.  I cant seem to consistently reproduce the behavior but occastionally when I try to save the data via...

                Me.Validate()
                Me.BindingSource.EndEdit()
                Me.TablAdapter.Update(Me.DataSet.MyTable)

    it will throw the error...

    "An overflow occurred while converting to datetime."

    So even though I could enter several records, when I save the data, this error throws and I lose all the new records I have entered.

    Does anybody have a clue as to what the heck could be causing this error?  If so, any ideas how I can fix it?  When looking at the data the dates all seem to be entering properly into the database?

    Thanks

    Mike







    Friday, March 30, 2007 8:10 PM

Answers

  • Hopefully this will save somebody A LOT of time down the road should they run into this problem.  It ends up that contrary to this error message, it actually has nothing to do with converting datetime, at least in my particular instance.  It took me forever to figure it out because the message was misleading.  This error message actually had to do with converting a 'decimal' datatype in my Visual Studio Dataset Designer to a  'numeric' data type in my SQLCE database which I apparently cannot do. Thus, I was looking in the wrong place.  To get it to work I changed my SQLCE datatype to 'float' and my Visual Studio Dataset Designer to 'double'.  The error no longer fires when I try to save the data.
    Monday, April 02, 2007 8:20 AM

All replies

  • Hopefully this will save somebody A LOT of time down the road should they run into this problem.  It ends up that contrary to this error message, it actually has nothing to do with converting datetime, at least in my particular instance.  It took me forever to figure it out because the message was misleading.  This error message actually had to do with converting a 'decimal' datatype in my Visual Studio Dataset Designer to a  'numeric' data type in my SQLCE database which I apparently cannot do. Thus, I was looking in the wrong place.  To get it to work I changed my SQLCE datatype to 'float' and my Visual Studio Dataset Designer to 'double'.  The error no longer fires when I try to save the data.
    Monday, April 02, 2007 8:20 AM
  • In our case, the overflow error was a result of trying to insert an uninitialized "System.DateTime" even though the value was null (Note: uninitialized DateTime is 1/1/0001 12:00:00 and not necessarily null) the value needs to be set explicitly to null for the insert so the Microsoft-dataset-generated-code will use "System.DBNull.Value" otherwise the DB driver throws a overflow error.

    Tuesday, March 11, 2008 6:32 PM
  • Yes, as described above I received this error but I had a numeric(9,4) column that was trying to store a large decimal value.
     
    Changing the column to numeric(28,4) fixed the issue.
     
    Tuesday, April 29, 2008 5:52 AM
  • Hi..

    I have the same issue as you mentioned. I am using SSIS to fetch the records from Oracle into SQL Compact Edition 3.5. When I fetch some records say for e.g. 1/1/0001 12:00:00 into SQL CE, it throws me an error "An Overflow occured while converting to datetime".

    Can You suugest me how I can resolve this datetime issue in SSIS  ?

    Many Thanks in Advance!!

    Regards,

    Bhavik Mandaliya

    Sunday, November 25, 2012 1:13 PM
  • Hi..

    I have the same issue as you mentioned. I am using SSIS to fetch the records from Oracle into SQL Compact Edition 3.5. When I fetch some records say for e.g. 1/1/0001 12:00:00 into SQL CE, it throws me an error "An Overflow occured while converting to datetime".

    Can You suggest me how I can resolve this datetime issue in SSIS  ?

    Many Thanks in Advance!!

    Regards,

    Bhavik Mandaliya

    Sunday, November 25, 2012 1:19 PM