开发者

Converting string to type date or type time

开发者 https://www.devze.com 2023-03-03 05:17 出处:网络
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:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消