using (SqlConnection conn = new SqlConnection())
{
conn.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
int History_num = 0;
SqlCommand Cmd = new SqlCommand();
String SelectSql = "SELECT [history_num] FROM [time_table]";
Cmd.CommandText = SelectSql;
Cmd.Connection = conn;
conn.Open();
SqlDataReader dr = Cmd.ExecuteReader();
if (dr.Read())
{
History_num = dr.GetInt32(0);
}
history_num.Text = History_num.ToString();
conn.Close();
conn.Dispose();
}
数据成功更新到数据库,在主页page_load中加入这段代码,前段通过控件设置1秒自动刷新,执行后显示数据不是实时数据,后台手动刷新数据库后前段立即显示实时数据,请问有什么解决办法