I have 2 columns in the database. One is of type Date and another is of type Time(7).
I am updating the values in the database through front end. For conve开发者_StackOverflowrsion I am doing:
(columnName of type Date) Start_Date = TextBox1.Text;
(columnName of type Time) Start_Time = TextBox2.Text;
And its giving me an conversion error from string to time... How can I convert it?
You need to create a DateTime
object from your textboxes and assign that to the columns. You could use DateTime.Parse(TextBox1.Text)
. Or also DateTime.ParseExact()
, depending on how much control you want to retain over the parsing of the date.
精彩评论