Hai friend in my project I want to save date in database table using date datatype. How can I do this please help me?
In my code i'm just call the datetimepicker text , but it was showing an error like system.datetime value is in string.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Upendra Pratap ShahiPosted Sep 2, 2015, 6:31 AM
Upendra Pratap ShahiPosted Sep 2, 2015, 7:18 AM
Pavithra LPosted Sep 2, 2015, 6:30 AM
Upendra Pratap ShahiPosted Sep 2, 2015, 6:07 AM
string sQry = "select yourDate from your_table ";
SqlConnection con = new SqlConnection(constr);
SqlCommand cmd = new SqlCommand(sQry, con);
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
string valj = dr["yourDate"].ToString();
dateTimePicker1.Text = valj;
}
con.Close();
Pavithra LPosted Sep 2, 2015, 5:40 AM
Pavithra LPosted Sep 2, 2015, 5:26 AM
Pavithra LPosted Sep 2, 2015, 5:25 AM
Raja TPosted Sep 2, 2015, 5:23 AM
Subhani ShaikhPosted Sep 2, 2015, 5:22 AM
Raja TPosted Sep 2, 2015, 5:19 AM
Raja TPosted Sep 2, 2015, 5:16 AM
Pavithra LPosted Sep 2, 2015, 5:16 AM
Raja TPosted Sep 2, 2015, 5:13 AM
Pavithra LPosted Sep 2, 2015, 5:07 AM
Raja TPosted Sep 2, 2015, 4:46 AM
Pavithra LPosted Sep 2, 2015, 4:37 AM
Raja TPosted Sep 2, 2015, 3:26 AM
Pavithra LPosted Sep 2, 2015, 3:12 AM
Pavithra LPosted Sep 2, 2015, 3:04 AM
this is my code for retrieve the data from database table . But it is not retrieve the date and only show the current date.Pavithra LPosted Sep 2, 2015, 2:55 AM
Pavithra LPosted Sep 2, 2015, 2:44 AM
Pavithra LPosted Sep 2, 2015, 2:37 AM
Raja TPosted Sep 2, 2015, 2:28 AM
Prem Anandh JPosted Sep 2, 2015, 2:23 AM
Pavithra LPosted Sep 2, 2015, 2:18 AM
Pavithra LPosted Sep 2, 2015, 2:14 AM
Raja TPosted Sep 2, 2015, 2:13 AM
Pavithra LPosted Sep 2, 2015, 2:07 AM
Prem Anandh JPosted Sep 2, 2015, 2:06 AM
Hi,
Just ensure the datatype of required field in Table.
Pavithra LPosted Sep 2, 2015, 2:03 AM
Pavithra LPosted Sep 2, 2015, 1:58 AM
Raja TPosted Sep 2, 2015, 1:54 AM
Manas MohapatraPosted Sep 2, 2015, 1:52 AM
Make sure that you select date picker in UI. Please try below code:MessageBox.Show("Selected date is " + iDate);Pavithra LPosted Sep 2, 2015, 1:51 AM
Prem Anandh JPosted Sep 2, 2015, 1:44 AM
Hi Pavithra,
depending upon database you may need to change the DTPicker string format.
Pavithra LPosted Sep 2, 2015, 1:37 AM
Pavithra LPosted Sep 2, 2015, 1:33 AM
Raja TPosted Sep 2, 2015, 1:26 AM
Manas MohapatraPosted Sep 2, 2015, 1:17 AM