Reputation: 287
This is the query I am having issues with:
cmd = new OleDbCommand(insert into tbl_Customer(cReportingTime) values (@ReportingTime)", con);
cmd.Parameters.Add("@ReportingTime", OleDbType.DBTime).Value = Time;
cmd.ExecuteNonQuery();
When I try to run it I am getting this error:
"Failed to convert parameter value from a DateTime to a TimeSpan"
I want to insert only time in MS Access database however I can't seem to get it to work.
Upvotes: 2
Views: 835
Reputation: 98740
I assume your Time
is a DateTime
, you can use it's TimeOfDay
property like;
cmd.Parameters.Add("@ReportingTime", OleDbType.DBTime).Value = Time.TimeOfDay;
Since DBTYPE_DBTIME
mapped with TimeSpan
, this should work.
Upvotes: 3