I want to create a column in my datatable which stores the current time. After that, I want to insert this column data to sql table where column datatype is “time”. Currently, I added a column to my existing datatable as below
But it is in string format and the datatype of column of sql is in “time” so there is a mismatch. How can I solve this problem?
Note: I do not want to use any custom library.
String type and time type are different. Have you tried to push data without parsing it to string?
Here you have some information about SQL date and time data types:
You can solve this problem by just changing the datatype of the column to
System.TimeSpan also change the default value to
Now.TimeOfDay that’s it