从数据库中选择时间值到datetimepicker [英] Select time value from database into datetimepicker

查看:143
本文介绍了从数据库中选择时间值到datetimepicker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我在从DataBase中选择SQL时间值到具有时间格式的DateTimePicker时出现问题。



Hello,

I'm having some problems with selecting SQL Time value from DataBase into DateTimePicker which has "Time" format.

            SqlConnection conn = new SqlConnection();
            conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ERS"].ConnectionString;
            string query = "select * from Reyestrator where guid = '" +guid+ "'";
            SqlCommand cmd = new SqlCommand(query, conn);
            SqlDataReader dbr;
            conn.Open();
            dbr = cmd.ExecuteReader();
            while (dbr.Read())
            {               
                dateTimePicker1.Value = Convert.ToDateTime(dbr["DataZgloszeniaZapotrzebowania"]);
.....
                comboBox7.Text = dbr["Forma"].ToString();
                dateTimePicker5.Value = Convert.ToDateTime(dbr["RealnyCzas"]);
                checkBox1.Checked = Convert.ToBoolean(dbr["DaneWrażliwe"]);
....
            }
            conn.Close();





Field I'有问题的是将RealnyCzas放在dateTimePicker5中。



任何想法我怎么能这样做?



The Field I'm having problems with is "RealnyCzas" placed in dateTimePicker5.

Any ideas how could I do this?

推荐答案

右键单击dateTimePicker5控件并更改其属性如下所示

Right click on dateTimePicker5 control and change its properties as below
dateTimePicker5.CustomFormat = "dd-MMM-yyyy hh:mm:ss tt";//Or Whatever format you want.
dateTimePicker5.Format = Custom;



我希望它有效。


I hope it works.


这篇关于从数据库中选择时间值到datetimepicker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆