|
-
Nov 20th, 2003, 05:03 PM
#1
Thread Starter
Registered User
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!!!
-
Nov 20th, 2003, 05:04 PM
#2
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.
-
Nov 20th, 2003, 06:41 PM
#3
Thread Starter
Registered User
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?
-
Nov 20th, 2003, 06:44 PM
#4
Wierd, what value is Now returning? Or better yet post your update code.
-
Nov 20th, 2003, 07:55 PM
#5
Thread Starter
Registered User
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
-
Nov 20th, 2003, 09:12 PM
#6
Very Strange so I am assuming that the property assignment goes as follows:
VB Code:
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.
-
Nov 20th, 2003, 09:44 PM
#7
Thread Starter
Registered User
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.
-
Nov 21st, 2003, 12:04 AM
#8
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
-
Nov 21st, 2003, 09:33 AM
#9
Thread Starter
Registered User
Yeah - I tried that too. No luck.
-
Nov 21st, 2003, 12:48 PM
#10
Try this:
drTicket.DateAdded = Date.Now.Today()
Do you HAVE to have the time in there too?
-
Nov 21st, 2003, 02:27 PM
#11
Thread Starter
Registered User
I do have to have the time although I did try to using the Today property as well and that didn't work either.
-
Nov 24th, 2003, 04:03 PM
#12
Thread Starter
Registered User
*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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|