Hi I have a program that uses DateTime.Now.ToString() to get the time and then plugs it into a coloum that is smalldatetime. This worked before but now I get this error.
“Arithmetic overflow error converting expression to data type datetime.
The statement has been terminated.”
What am I doing wrong?
This is my SQL statement
command.CommandText = @" INSERT INTO Mail1 (UserID, Subject, Feedback, Date_Sent_On)
VALUES (@UserID, @Subject, @Feedback, @Date_Sent_On)";
The
@Date_Sent_Onparameter should be of typeDateTimeinstead ofstringand you should passDateTime.Nowas its value.Using
DateTime.Now.ToString()is very unreliable, because formatting the date withToString()is culture dependent – it can produce different results depending on the regional settings of your computer and the culture settings in the application.