Results 1 to 12 of 12

Thread: SqlDateTime overflow

  1. #1

    Thread Starter
    Registered User
    Join Date
    Mar 2002
    Location
    Nashville, TN
    Posts
    103

    Question SqlDateTime overflow

    I am using ADO.Net to insert a record into a table. One of the fields is receiving the value from Now() (i.e. the current datetime). However, when I call the update method of the dataadapter I get the following error:

    Sqldatetime overflow. Must be between 1/1/1753 12:00:00AM and 12/31/1999 11:59:59PM.

    Why would this happen? I checked the settings on the server and it is set to interpret 2 digit dates between 1950 and 2049 so I know that's not the problem. What could be causing this? I've NEVER seen this happen before.

    Please help!!!

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    It sounds like you are using a SQL SmallDate field. Drop the small or try using a Date type in the app instead of DateTime.

  3. #3

    Thread Starter
    Registered User
    Join Date
    Mar 2002
    Location
    Nashville, TN
    Posts
    103
    I am using the standard datetime SQL datatype in (not smalldate) and I am sending it a Date value (I'm using the Now() function which is a Date datatype in VB.NET). Any other thoughts/ideas?

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Wierd, what value is Now returning? Or better yet post your update code.

  5. #5

    Thread Starter
    Registered User
    Join Date
    Mar 2002
    Location
    Nashville, TN
    Posts
    103
    I just ran the code and Now() is returning 11/20/2003 6:52:49 PM. Here is my update code:

    If drTicket.RowState = DataRowState.Detached Then dsTicketHdr.TicketHdr.Rows.Add(drTicket)

    daTicketHdr.Update(dsTicketHdr.TicketHdr)
    drTicket.AcceptChanges()
    dsTicketHdr.TicketHdr.AcceptChanges()

    Hope this helps

  6. #6
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Very Strange so I am assuming that the property assignment goes as follows:
    VB Code:
    1. drTicket("MyDateField")=Date.Now

    If you haven't had problems in the past, and I never have either than its got to be something small that is being overlooked.

  7. #7

    Thread Starter
    Registered User
    Join Date
    Mar 2002
    Location
    Nashville, TN
    Posts
    103
    Close - since this is a predefined datatable, it looks like this:

    drTicket.DateAdded = DateTime.Parse(Now())

    I've also tried:

    drTicket.DateAdded = Now()
    drTicket.DateAdded = CDate(Format(Now(), "MM/dd/yyyy hh:mm:ss"))

    None of these work either.

  8. #8
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    I doubt this is it but you shouldn't need to parse it since Now returns a date. Try:

    drTicket.DateAdded = Date.Now() 'or DateTime.Now() both return a date

  9. #9

    Thread Starter
    Registered User
    Join Date
    Mar 2002
    Location
    Nashville, TN
    Posts
    103
    Yeah - I tried that too. No luck.

  10. #10
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Try this:

    drTicket.DateAdded = Date.Now.Today()

    Do you HAVE to have the time in there too?

  11. #11

    Thread Starter
    Registered User
    Join Date
    Mar 2002
    Location
    Nashville, TN
    Posts
    103
    I do have to have the time although I did try to using the Today property as well and that didn't work either.

  12. #12

    Thread Starter
    Registered User
    Join Date
    Mar 2002
    Location
    Nashville, TN
    Posts
    103
    *bump*

    Anyone have any more thoughts on this? i am really stuck.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width