之前的这个页面运行都是好的,现在是这样的,半天才能打开,有时候就报超时时间已经到了,我知道可能将session设置时间长点会不报错的,可是这样的体验太差了, DataSet ds = new DataSet();
da.Fill(ds, "profile");//这一步就报超时时间一到,怎么解决的啊

解决方案 »

  1.   

     protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
              //字段排序操作
                int sumPage;
                int pageNo = 1;
                int pageSize = 20;
                if (Request.QueryString["CurrentPage"] == null)
                {
                    pageNo = 1;
                }
                else
                {
                    pageNo = Int32.Parse(Request.QueryString["CurrentPage"]);            }            string tablist = "a.id,a.jobname,a.flag,a.jobcode,a.recruiter,a.manager,a.job_time,a.region,convert(varchar(20),a.intime,23) as intime,a.edittime,a.xmsession,a.department,(select count(*) as num1 from cvsession b,cvresume c where b.xmid = a.id and b.cvsession = '已申请' and c.id = b.cvid) as num1,(select count(*) as num1 from cvsession b,cvresume c where b.xmid = a.id and b.cvsession != '已申请' and c.id = b.cvid) as num2,(select count(*) as num1 from cvsession b,cvresume c where b.xmid = a.id and c.id = b.cvid) as num3,(select count(*) as num from colog where xmid=a.id and (type='11' or type='12' or type='13' or type='14' or type='16' or type='23')) as lognum";
                string tabname = "xm a";
                string wh = "company = '" + Session["company"].ToString() + "'";
                string keywords = Server.UrlDecode(function.Filter(function.Vall("keywords")));
                if (Session["Culture"].ToString().Trim() == "zh-cn")
                {
                    if (keywords != null && keywords != "" && keywords != "请输入职位筛选关键字")
                    {
                        string[] key = keywords.Split(' ');
                        for (int i = 0; i < key.Length; i++)
                        {
                            wh = wh + " and (CONTAINS(*, '" + key[i] + "' ) or jobcode like '%" + key[i] + "%')";
                        }
                    }
                }
                else if (Session["Culture"].ToString().Trim() == "en-us")
                {
                    if (keywords != null && keywords != "" && keywords != "Search Keywords")
                    {
                        string[] key = keywords.Split(' ');
                        for (int i = 0; i < key.Length; i++)
                        {
                            wh = wh + " and (CONTAINS(*, '" + key[i] + "' ) or jobcode like '%" + key[i] + "%')";
                        }
                    }
                }
                string recruiters = Server.UrlDecode(function.Vall("recruiters"));
                if (recruiters != "" && recruiters != Resources.Strings.literal642)
                {
                    wh = wh + " and a.recruiter like '%," + recruiters + ",%'";
                }
                string departments = Server.UrlDecode(function.Vall("departments"));
                if (departments != "" && departments != Resources.Strings.literal643)
                {
                    wh = wh + " and a.department = '" + departments + "'";
                }
                string xmsessions = Server.UrlDecode(function.Vall("xmsessions"));
                if (xmsessions != "" && xmsessions != Resources.Strings.literal644)
                {
                    if (Session["Culture"].ToString().Trim() == "en-us")
                    {
                        if (xmsessions == "Active")
                        {
                            xmsessions = "进行中";
                            wh = wh + " and a.xmsession = '" + xmsessions + "'";
                        }
                        else if (xmsessions == "Hold")
                        {
                            xmsessions = "搁置";
                            wh = wh + " and a.xmsession = '" + xmsessions + "'";
                        }
                        else if (xmsessions == "Draft")
                        {
                            xmsessions = "草稿";
                            wh = wh + " and a.xmsession = '" + xmsessions + "'";
                        }
                        else if (xmsessions == "Closed")
                        {
                            xmsessions = "完成";
                            wh = wh + " and a.xmsession = '" + xmsessions + "'";
                        }
                        else if (xmsessions == "Cancelled")
                        {
                            xmsessions = "取消";
                            wh = wh + " and a.xmsession = '" + xmsessions + "'";
                        }
                    }
                    else
                    {
                        if (xmsessions == "进行中")
                        {
                            wh = wh + " and a.xmsession = '" + xmsessions + "'";
                        }
                        else if (xmsessions == "搁置")
                        {
                            wh = wh + " and a.xmsession = '" + xmsessions + "'";
                        }
                        else if (xmsessions == "草稿")
                        {
                            wh = wh + " and a.xmsession = '" + xmsessions + "'";
                        }
                        else if (xmsessions == "完成")
                        {
                            wh = wh + " and a.xmsession = '" + xmsessions + "'";
                        }
                        else if (xmsessions == "取消")
                        {
                            wh = wh + " and a.xmsession = '" + xmsessions + "'";
                        }
                    }
                }
                         if (limit == "0")
                {
                    string us = "";
                    string mySql1 = "select username from colist where id = '" + Session["coid"].ToString() + "'";
                    SqlCommand myCmd1 = new SqlCommand(mySql1, myConn);
                    myCmd1.Connection.Open();
                    SqlDataReader dr1 = myCmd1.ExecuteReader();
                    if (dr1.Read())
                    {
                        us = "," + dr1["username"].ToString().Trim() + ",";
                    }
                    dr1.Close();
                    myCmd1.Connection.Close();                wh = wh + " and recruiter like '%" + us + "%'";
                }
                SqlDataAdapter da = new SqlDataAdapter();
                da.SelectCommand = new SqlCommand();
                da.SelectCommand.Connection = myConn;
                da.SelectCommand.CommandText = "getdataset";
                da.SelectCommand.CommandType = CommandType.StoredProcedure;
                da.SelectCommand.Parameters.Add("@TableList", SqlDbType.VarChar, 1000).Value = tablist;
                da.SelectCommand.Parameters.Add("@TableName", SqlDbType.VarChar, 30).Value = tabname;
                da.SelectCommand.Parameters.Add("@SelectWhere", SqlDbType.VarChar, 2000).Value = wh;
                da.SelectCommand.Parameters.Add("@SelectOrderId", SqlDbType.VarChar, 20).Value = "a.id";
                da.SelectCommand.Parameters.Add("@SelectOrder", SqlDbType.VarChar, 200).Value = selectorder;
                da.SelectCommand.Parameters.Add("@intPageNo", SqlDbType.Int).Value = pageNo;
                da.SelectCommand.Parameters.Add("@intPageSize", SqlDbType.Int).Value = pageSize;
                da.SelectCommand.Parameters.Add("@RecordCount", SqlDbType.Int).Direction = ParameterDirection.Output;
                da.SelectCommand.Parameters.Add("RowCount", SqlDbType.Int).Direction = ParameterDirection.ReturnValue;
                DataSet ds = new DataSet();
                da.Fill(ds, "profile");
                Int32 RecordCount = (Int32)da.SelectCommand.Parameters["@RecordCount"].Value;
                Int32 RowCount = (Int32)da.SelectCommand.Parameters["RowCount"].Value;                       GridView1.DataSource = ds;
                    GridView1.DataBind();
                myConn.Close();
    }
      

  2.   

    什么错误提示啊?
    如果还是服务器超时的话,我猜测是你数据库数据太多了。。至少300+
    服务器超时是你连接没关好 就是close还是不够的 要销毁他!
      

  3.   

    我也查出来来,是,(select count(*) as num from colog where xmid=a.id and (type='11' or type='12' or type='13' or type='14' or type='16' or type='23')) as lognum  里面的or有问题,问题是我将or换成了UNION也还是慢,谁有改善的办法吗