asp.net 执行这样的代码会效率么,求大神解答,谢了
protected void bindggd()
{
using (SqlConnection conn = new SqlConnection(Conn.CONN_STRING))
{
if (Cache["xiaochi"] == null)
{
StringBuilder sb = new StringBuilder("select top 5 KeyId,CategoryId,Title from XF_News where CategoryId=18 and ShenHe=1 order by TuiJian desc,Orders desc,KeyId desc;");
sb.Append("select PicPathS,Title,TitleLinkUrl from XF_News where CategoryId=19 and ShenHe=1 order by TuiJian desc,Orders desc,KeyId desc;");
sb.Append("select * from win_sdtime;");
DataSet ds = SqlHelper.ExecuteDataset(conn, CommandType.Text, sb.ToString());
Cache.Insert("xiaochi", ds, null, DateTime.Now.AddMinutes(10), TimeSpan.Zero);
rptitemgg.DataSource = ds.Tables[0];
rptitemgg.DataBind();
rprBanner.DataSource = ds.Tables[1];
rprBanner.DataBind();
dqtime.InnerText =ds.Tables[2].Rows[0]["stimeOne"].ToString();
dqtimem.InnerText =ds.Tables[2].Rows[0["stimeTwo"].ToString();
hdtime.InnerText =ds.Tables[2].Rows[0["stimeThree"].ToString();
hdtimem.InnerText=ds.Tables[2].Rows[0]["stimeFour"].ToString();
}
else
{
DataSet ds = (DataSet)Cache["xiaochi"];
rptitemgg.DataSource = ds.Tables[0];
rptitemgg.DataBind();
rprBanner.DataSource = ds.Tables[1];
rprBanner.DataBind();
dqtime.InnerText = ds.Tables[2].Rows[0]["stimeOne"].ToString();
dqtimem.InnerText = ds.Tables[2].Rows[0]["stimeTwo"].ToString();
hdtime.InnerText = ds.Tables[2].Rows[0]["stimeThree"].ToString();
hdtimem.InnerText = ds.Tables[2].Rows[0]["stimeFour"].ToString();
}
}
}
{
using (SqlConnection conn = new SqlConnection(Conn.CONN_STRING))
{
if (Cache["xiaochi"] == null)
{
StringBuilder sb = new StringBuilder("select top 5 KeyId,CategoryId,Title from XF_News where CategoryId=18 and ShenHe=1 order by TuiJian desc,Orders desc,KeyId desc;");
sb.Append("select PicPathS,Title,TitleLinkUrl from XF_News where CategoryId=19 and ShenHe=1 order by TuiJian desc,Orders desc,KeyId desc;");
sb.Append("select * from win_sdtime;");
DataSet ds = SqlHelper.ExecuteDataset(conn, CommandType.Text, sb.ToString());
Cache.Insert("xiaochi", ds, null, DateTime.Now.AddMinutes(10), TimeSpan.Zero);
rptitemgg.DataSource = ds.Tables[0];
rptitemgg.DataBind();
rprBanner.DataSource = ds.Tables[1];
rprBanner.DataBind();
dqtime.InnerText =ds.Tables[2].Rows[0]["stimeOne"].ToString();
dqtimem.InnerText =ds.Tables[2].Rows[0["stimeTwo"].ToString();
hdtime.InnerText =ds.Tables[2].Rows[0["stimeThree"].ToString();
hdtimem.InnerText=ds.Tables[2].Rows[0]["stimeFour"].ToString();
}
else
{
DataSet ds = (DataSet)Cache["xiaochi"];
rptitemgg.DataSource = ds.Tables[0];
rptitemgg.DataBind();
rprBanner.DataSource = ds.Tables[1];
rprBanner.DataBind();
dqtime.InnerText = ds.Tables[2].Rows[0]["stimeOne"].ToString();
dqtimem.InnerText = ds.Tables[2].Rows[0]["stimeTwo"].ToString();
hdtime.InnerText = ds.Tables[2].Rows[0]["stimeThree"].ToString();
hdtimem.InnerText = ds.Tables[2].Rows[0]["stimeFour"].ToString();
}
}
}
...全文
相关推荐
ASP.NET入门问题解答
ASP.NET入门问题解答
ASP.NET 应用开发常用代码与技巧大全
本文还有配套的精品资源,点击获取 简介:ASP.NET是基于.NET Framework的框架,用于构建Web应用程序。本资源包包含基础知识、问题解答和实用技巧的集合,涵盖页面生命周期、控件事件、数据绑定、异常处理、安全性等关键领域。特别为初学者准备,提供从基础到高级的应用程序创建教程、常用函数表、用户控件使用、架构概览、快捷代码片段、JavaScript小技巧以及社区讨论...
ASP.NET3.5最佳实践课后测验解答
ASP.NET 3.5 最佳实践 课后解答 郑淑芬 ASP.NET3.5 最佳实践源代码郑淑芬 http://download.csdn.net/source/2055731
ASP.NET常见问题解答
网站开发中的常见问题,适用初步开发网站者
asp.net专家疑难解答200问
asp.net专家疑难解答200问,可以解决一些相对来说比较因难的问题。


