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 入门常见问题进行解答。1.
ASP.NET 应用开发常用代码与技巧大全
本文还有配套的精品资源,点击获取 简介:ASP.NET是基于.NET Framework的框架,用于构建Web应用程序。本资源包包含基础知识、问题解答和实用技巧的集合,涵盖页面生命周期、控件事件、数据绑定、异常处理、安全性等关键领域。特别为初学者准备,提供从基础到高级的应用程序创建教程、常用函数表、用户控件使用、架构概览、快捷代码片段、JavaScript小技巧以及社区讨论...
ASP.NET3.5最佳实践课后测验解答
课后测验解答通常涵盖以上这些关键点,通过解答,学习者可以检查自己的理解,发现盲点,并加深对ASP.NET 3.5最佳实践的理解。同时,提供的源代码能帮助学习者实践和学习实际应用中的编程技巧。
ASP.NET常见问题解答
以下是一些关于ASP.NET开发过程中的关键知识点和常见问题解答:1.
asp.net专家疑难解答200问
这本书或资料集旨在帮助开发者解决在实际开发过程中可能遇到的棘手问题,提升开发效率和代码质量。1.



