Hi,
I retrive date from database. It is in the format of yyyy-mm-dd.
Now i want to put this date into masked textbox. Masked text box date format is dd-mm-yyyy.
I am not getting correct date format in my masked textbox.
Darma
Retrieve date from sql and store it in a textbox
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Sudhakar ChaudharyRank #1,379 · 1.2K reputationPosted Jul 23, 2012, 4:13 AM EDT
{
con.Open();
}
SqlCommand cmd = new SqlCommand("select convert(varchar(10),date,103)as date from table1", con);
maskedTextBox1.Text = (string)cmd.ExecuteScalar();
SqlCommand cmd = new SqlCommand("insert into table1 values('','','','" + Convert.ToDateTime(maskedTextBox1.Text).ToLongDateString() + "')", con);
if (con.State == ConnectionState.Closed)
{
con.Open();
}
cmd.ExecuteNonQuery();
Abhijit baruaRank #3,722 · 397 reputationPosted Jul 23, 2012, 4:10 AM EDT