Click here to Skip to main content
15,916,398 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear All,

I need to update time from Database in label control.

whatever the time is in database it should update in asp.net page label.

For Example : I have a table called LastUpdatedTable..in this i have a column with Name LastUpdatedAt.

So this column i must display in label....so it will display time.

Just I need to display the Database time in Label.

Please help.
Posted
Comments
MT_ 1-Oct-12 6:44am    
At what event you need to update it ? On page load ?
Achha Insan 2-Oct-12 3:14am    
nothing is impossible. you can do it.

As i understood your question... check this.


SqlConnection con=new SqlConnection("");
SqlCommand cmd=new SqlCommand("select time_column from table where condition",con);
con.Open();
SqlDataReader dr=cmd.ExecuteReader();
if (dr.HasRows)
{
while (dr.Read())
{
Label1.Text = dr[0].ToString();
}
}


If any query let me know..
 
Share this answer
 
Comments
Software Engineer 892 1-Oct-12 7:27am    
Thanks Raghu Gowda

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