Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
Arithmetic overflow error converting expression to data type datetime.


What I have tried:

SqlCommand cmd1 = new SqlCommand("insert into Attendence values(@Engi_Profile_ID,@In_Date_Time,@In_Date_Only,@Out_Date_Time,@Reason,@Remark,@Flag)", con);


{
SqlCommand cmd1 = new SqlCommand("insert into Attendence values(@Engi_Profile_ID,@In_Date_Time,@In_Date_Only,@Out_Date_Time,@Reason,@Remark,@Flag)", con);
cmd1.Parameters.AddWithValue("@Engi_Profile_ID", txtID.Text.ToString());

}

cmd1.ExecuteNonQuery(); then give error actually Arithmetic overflow error converting expression to data type datetime.
Posted
Updated 14-Apr-16 1:50am

It means whatever you are trying to put into a datetime parameter is way too big. Just debug your code and you'll see what the values are. Pretty quick and simple to fix.
 
Share this answer
 
Convert txtID.Text to a DateTime type using DateTime.TryParse, or DateTime.TryParseExact (google for examples) and add the DateTime variable to the parameter instead.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900