Click here to Skip to main content
15,879,613 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how can i put a date in my datetimepiker from a request sql
Prerak Patel 18-Aug-11 6:58am    
Not clear
amineel9 18-Aug-11 6:59am    
i take my data from my sql data base and i would to put a date in a date time picjer how can i do it ?

Read the value from the database in your usual manner, and set the DateTimePicker Value property:
myDateTimePicker.Value = new DateTime(1994, 11, 17);
Share this answer
amineel9 18-Aug-11 7:04am    
i test DateTimePicker1.Text = dtr.getdatetime(5) but it does'nt work
OriginalGriff 18-Aug-11 7:10am    
Read the answer: myDateTimePicker.Value not myDateTimePicker.Text
This[^] may help.
Share this answer
I think you want to put Date value from your database to DateTimePicker control, if I am not wrong.

You can do this by assigning your Date value to DateTimePicker's Value property like this

DateTimePicker.Value =Convert.ToDateTime(DataRow(0)("date")) 
Share this answer
amineel9 18-Aug-11 7:17am    
but i take a date from a data readre you see?
modifparam.DateTimePicker1.Value = dtr.GetDateTime(5).ToShortDateString
that's the solution it's work thks you all :)
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900