I have to save a time to sqlserver2008 db as time(7)
data type which is in string format in code behind.how can I convert it to that data type.My code getting error
string time='9.30 pm';
modal db=new modal();
db.time=Timespan.Parse(time);
context.modal.Add(db);
context.SaveChanges();
in db,time as time(7)
datatype
error is
An exception of type
'System.FormatException'
occurred inmscorlib.dll
but was not handled in user code. Additional information: String was not recognized as a valid TimeSpan.
Based on this answer, you can do this: