I am trying to insert value retrieved from Now() into a datetime field in my MSDE database, but I am getting the following error, and I have no idea what is going wrong.
Arithmetic overflow error converting expression to data type datetime.
The statement has been terminated.
Here is the code I am using:With SqlOrders.InsertParametersDim user As String = MyContext.User.Identity.Name.ToString
Dim TimeDate As DateTime = Now()
Dim status As String = "Pending"
.Item("UserName").DefaultValue = user
.Item("OrderDate").DefaultValue = TimeDate
.Item("Status").DefaultValue = status
End With
SqlOrders.Insert()
The date is being returned in this format23/03/2006 02:01:52, which is the same format as it should appear in the database.
could anyone please tell me where I am going wrong?
Datetimes don't have a format. Varchar/strings that represent a datetime have a format. Make sure your OrderDate parameter is set to a datetime datatype, and your problem should go away, probably.|||Thankyou, I added .Item("OrderDate").Type = TypeCode.DateTime and it works fine now :)
No comments:
Post a Comment