if(!Page.IsPostBack)
{
SqlConnection conn = new SqlConnection(con);
conn.Open();
string strSql = "select count(id) as countID from 公告";
SqlCommand cm = new SqlCommand(strSql,conn);
string intCount = cm.ExecuteScalar().ToString();
conn.Close();
Label1.Text = intCount;
}
博客展示了一段ASP.NET代码,在页面非回发时,通过SqlConnection连接数据库,执行SQL语句查询公告表中的记录数量,将结果转换为字符串后显示在Label1控件上,涉及数据库操作和字符串处理。
554

被折叠的 条评论
为什么被折叠?



