如何在标签中显示数据库时间 [英] How to display Database time in label

查看:97
本文介绍了如何在标签中显示数据库时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,

我需要在标签控件中从数据库更新时间.

无论数据库中的时间是多少,都应该在asp.net页面标签中进行更新.

例如:我有一个名为LastUpdatedTable ..的表,其中有一个名为LastUpdatedAt的列.

因此,此列我必须在标签中显示....以便显示时间.

我只需要在标签中显示数据库时间即可.

请帮忙.

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.

推荐答案

^ ]

http://www.daniweb.com/web-development/aspnet/threads/35687/login-and-retrieve-user-data-from-database [> http://www.daniweb.com/web-development/aspnet/threads/302548/how-to-populate-a-label-control-from-sql-server-database [
http://www.daniweb.com/web-development/aspnet/threads/62136/how-to-show-data-from-database-in-label[^]

http://www.daniweb.com/web-development/aspnet/threads/35687/login-and-retrieve-user-data-from-database[^]

http://www.daniweb.com/web-development/aspnet/threads/302548/how-to-populate-a-label-control-from-sql-server-database[^]

check this 3 links..it have ur answer


据我所知,您的问题...检查此.


SqlConnection con =新的SqlConnection(");
SqlCommand cmd =新的SqlCommand(从条件中的表中选择time_column",con);
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
如果(dr.HasRows)
{
while(dr.Read())
{
Label1.Text = dr [0] .ToString();
}
}


如有疑问,请告诉我..
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..


这篇关于如何在标签中显示数据库时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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