超时周期没有过去,但还是超时(见$ C $三)? [英] Time out period not elapsed, but still timing out (see code)?

查看:90
本文介绍了超时周期没有过去,但还是超时(见$ C $三)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

OK我一直在约3-4分钟,搅动后,收到此错误:

 超时过期。完成操作或服务器之前已超时期间没有响应。
说明:执行当前Web请求的执行过程中发生未处理的异常。请查看有关错误的详细信息的堆栈跟踪以及它起源于code。异常详细信息:System.Data.SqlClient.SqlException:超时过期。完成操作或服务器之前已超时期间没有响应。源错误:93号线:
94号线:DataSet中的getData;
95号线:=的getData SqlHelper.ExecuteDataset(ConfigurationManager.ConnectionStrings [connstr]的ConnectionString,CommandType.StoredProcedure,Course_NewReportGet_Get_Sav,objPara);
96号线:
97号线:的foreach(在getData.Tables的DataRow博士[0] .Rows)

下面是code,我觉得我没有做正确的事,我的超时设置为5000秒虽然所以它必须是别的东西。你会发现它的过程调用相当嵌套循环。我得到每家公司,然后让分配给每个公司每个课程,然后为每个当然我让所有的用户活动的报告。有一个关于250家企业,每2-70业公司在任何地方的课程,并且每场报告8 1000个用户,每家公司...所以我们正在处理大量的数据在这里。到了get报告最后的呼叫​​是pretty海量存储过程也...

我试图将数据转换成一种新的形式,这将使它更快,更容易与后来的工作,但现在我必须通过我们所拥有的解析,并在新的方式张贴。这是所有在同一个数据库,但我不完全知道我会怎么做这一切在短短的SQL。基本上,现在用的是使用我们的报表工具来获取数据发布到新表的存储过程。但我需要运行的程序为每门课程每家公司,然后发布数据在从每家公司的每个培训班的报告返回的每个用户...这是巨大的...

 使用系统;
使用System.Configuration;
使用System.Data这;
使用System.Linq的;
使用的System.Web;
使用System.Web.Security;
使用System.Web.UI程序;
使用System.Web.UI.HtmlControls;
使用System.Web.UI.WebControls;
使用System.Web.UI.WebControls.WebParts;
使用System.Xml.Linq的;
使用System.Data.SqlClient的;
使用Mexico.Data;公共部分类admin_tools_Optimus:System.Web.UI.Page
{
    保护INT步骤= 0;
    受保护的String [] =公司新的字符串[260];
    受保护的String [] = coursestrings新的字符串[260];
    保护INT总= 0;
    保护INT [] = totalcourses新INT [260];    保护无效的Page_Load(对象发件人,EventArgs的发送)
    {    }    保护无效继续(对象发件人,EventArgs的发送)
    {
        数据集getCompanies = SqlHelper.ExecuteDataset(ConfigurationManager.ConnectionStrings [connstr]的ConnectionString,CommandType.StoredProcedure,Companies_All_Get);        INT计数器= 0;        的foreach(在getCompanies.Tables的DataRow博士[0] .Rows)
        {
            lstData.Items.Add(DR [companyid]的ToString()+:+博士[公司名称]的ToString());
            公司[计数器] =博士[companyid]的ToString()。
            反++;
        }
        lblCurrentData.Text = counter.ToString()+公司准备好了,点击旁边的获得所有公司的课程。
        总=计数器;        GetCompanies();
    }
    保护无效GetCompanies()
    {
        字符串[,]场=新的字符串[260,200];        的for(int i = 0; I<总-1;我++)
        {
            数据集getBundles = SqlHelper.ExecuteDataset(ConfigurationManager.ConnectionStrings [connstr]的ConnectionString,CommandType.StoredProcedure,CompanyCourses_ByCompanyID_Get_Sav,新的SqlParameter(@ companyid,公司由[i]));            INT计数器= 0;            的foreach(在getBundles.Tables的DataRow博士[0] .Rows)
            {
                课程[我,计数器] =博士[bundleid]的ToString()。
                反++;
            }            字符串[ALLID =;            [ALLID + =课程[I,0];            为(中间体二= 0;二<反向;ⅱ++)
            {
                [ALLID + =,+课程[I,II];
            }
            回复于([ALLID +< BR />中);
            coursestrings [I] = [ALLID;
            totalcourses [I] =计数器;
        }
        GetUsers();
    }    保护无效GetUsers()
    {
        的for(int i = 0; I<总 - 1;我++)
        {
            的SqlParameter [] = objPara新的SqlParameter [10];
            objPara [0] =新的SqlParameter(@ CompanyID,公司[I]);
            objPara [1] =新的SqlParameter(@ CourseID,coursestrings [I]);
            objPara [2] =新的SqlParameter(@ DateRangeType,1);
            // objPara [3] =新的SqlParameter(@起始日期的startDate);
            // objPara [4] =新的SqlParameter(@结束日期,System.DateTime.Now.ToString(MM / DD / YYYY));
            objPara [5] =新的SqlParameter(@用户名,);
            objPara [6] =新的SqlParameter(@开始索引,1);
            objPara [7] =新的SqlParameter(@ MaximumRows,100000);            DataSet中的getData;
            的getData = SqlHelper.ExecuteDataset(ConfigurationManager.ConnectionStrings [connstr]的ConnectionString,CommandType.StoredProcedure,Course_NewReportGet_Get_Sav,objPara);            的foreach(在getData.Tables的DataRow博士[0] .Rows)
            {
                。的Response.Write(用户+ DR [将把userid]的ToString()+/课程:+博士[bundleid]的ToString()+ - 进步:+博士[观看。的ToString()+ - 进球:+博士[拿下]的ToString()+< BR />< BR />中)。
            }
        }
    }
}

PAGE code:

 <%@页面语言=C#AutoEventWireup =真codeFILE =Optimus.aspx.cs继承=admin_tools_Optimus调试=真正的% >!< D​​OCTYPE HTML PUBLIC -  // W3C // DTD XHTML 1.0过渡// ENhttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">< HTML的xmlns =htt​​p://www.w3.org/1999/xhtml>
<头=服务器>
    <标题>无标题页< /标题>
< /头>
<身体GT;
    <表ID =form1的=服务器>
    < D​​IV>
        < ASP:标签ID =lblCurrentData=服务器文本=点击旁边的获得所有公司/>< BR />
        < ASP:按钮的ID =btnN​​ext=服务器文本=下一步的OnClick =继续/>
        < BR />
        < ASP:列表框ID =lstData=服务器HEIGHT =300WIDTH =300/>
    < / DIV>
    < /表及GT;
< /身体GT;
< / HTML>


解决方案

它看起来像超时正在发生的事情,当你正在运行的SQL存储过程(你的例外是SQLException类型)。你可能需要增加你的SQL存储过程的执行超时,但我不认为你可以做到这一点与提供SQLHelper类。

您需要去与SqlCommand类,并设置超时那里。

OK I keep getting this error after about 3-4 minutes of churning:

 Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.

Source Error:

Line 93: 
Line 94:             DataSet getData;
Line 95:             getData = SqlHelper.ExecuteDataset(ConfigurationManager.ConnectionStrings["connstr"].ConnectionString, CommandType.StoredProcedure, "Course_NewReportGet_Get_Sav", objPara);
Line 96: 
Line 97:             foreach (DataRow dr in getData.Tables[0].Rows)

Here is the code, I think I am not doing something properly, I set the timeout to 5000 seconds though so it must be something else. You'll notice it's quite the nested loop of procedure calls. I am getting every Company, then getting every Course assigned to each Company, then for each course I am getting a report of all the users activity. There is about 250 companies, anywhere from 2-70 courses per comapany, and from 8 to 1000 users per course report, per company... so we're dealing with a lot of data here. That final call to the get report is a pretty massive stored procedure also...

I am trying to transform the data into a new form that will make it faster and easier to work with later but for now I have to parse through what we have and post it in the new way. It is all in the same database but I am not exactly sure how I would do this all in just SQL. Basically am using a stored procedure that is used by our reporting tools to get the data to post to the new table. But I need to run the procedure for each course for each company and then post the data for each user returned in the report from each course from each company... It's huge...

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using Mexico.Data;

public partial class admin_tools_Optimus : System.Web.UI.Page
{
    protected int step = 0;
    protected string[] companies = new string[260];
    protected string[] coursestrings = new string[260];
    protected int total = 0;
    protected int[] totalcourses = new int[260];

    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void Proceed(object sender, EventArgs e)
    {
        DataSet getCompanies = SqlHelper.ExecuteDataset(ConfigurationManager.ConnectionStrings["connstr"].ConnectionString, CommandType.StoredProcedure, "Companies_All_Get");

        int counter = 0;

        foreach (DataRow dr in getCompanies.Tables[0].Rows)
        {
            lstData.Items.Add(dr["companyid"].ToString() + ": " + dr["companyname"].ToString());
            companies[counter] = dr["companyid"].ToString();
            counter++;
        }
        lblCurrentData.Text = counter.ToString() + " companies ready, click next to get all company courses.";
        total = counter;

        GetCompanies();
    }


    protected void GetCompanies()
    {
        string[,] courses = new string[260, 200];

        for (int i = 0; i < total-1; i++)
        {
            DataSet getBundles = SqlHelper.ExecuteDataset(ConfigurationManager.ConnectionStrings["connstr"].ConnectionString, CommandType.StoredProcedure, "CompanyCourses_ByCompanyID_Get_Sav", new SqlParameter("@companyid", companies[i]));

            int counter = 0;

            foreach (DataRow dr in getBundles.Tables[0].Rows)
            {
                courses[i, counter] = dr["bundleid"].ToString();
                counter++;
            }

            string allID = "";

            allID += courses[i, 0];

            for (int ii = 0; ii < counter; ii++)
            {
                allID += "," + courses[i, ii];
            }
            Response.Write(allID + " <br/>");
            coursestrings[i] = allID;
            totalcourses[i] = counter;
        }
        GetUsers();
    }

    protected void GetUsers()
    {
        for (int i = 0; i < total - 1; i++)
        {
            SqlParameter[] objPara = new SqlParameter[10];
            objPara[0] = new SqlParameter("@CompanyID", companies[i]);
            objPara[1] = new SqlParameter("@CourseID", coursestrings[i]);
            objPara[2] = new SqlParameter("@DateRangeType", 1);
            //objPara[3] = new SqlParameter("@StartDate", startDate);
            //objPara[4] = new SqlParameter("@EndDate", System.DateTime.Now.ToString("MM/dd/yyyy"));
            objPara[5] = new SqlParameter("@UserName", "");
            objPara[6] = new SqlParameter("@StartIndex", 1);
            objPara[7] = new SqlParameter("@MaximumRows", 100000);



            DataSet getData;
            getData = SqlHelper.ExecuteDataset(ConfigurationManager.ConnectionStrings["connstr"].ConnectionString, CommandType.StoredProcedure, "Course_NewReportGet_Get_Sav", objPara);

            foreach (DataRow dr in getData.Tables[0].Rows)
            {
                Response.Write("user: " + dr["userid"].ToString() + " / course: " + dr["bundleid"].ToString() + " - progress: " + dr["viewed"].ToString() + " - scored: " + dr["scored"].ToString() + "<br/><br/>");
            }
        }
    }
}

PAGE CODE:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Optimus.aspx.cs" Inherits="admin_tools_Optimus" Debug="true" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label ID="lblCurrentData" runat="server" Text="Click next to get all Companies"/><br />
        <asp:Button ID="btnNext" runat="server" Text="Next" OnClick="Proceed" />
        <br/>
        <asp:ListBox ID="lstData" runat="server" height="300" Width="300" />
    </div>
    </form>
</body>
</html>

解决方案

It looks like the timeout is happening when you're running the sql stored procedure (Your exception is of type SqlException). You would need to increase the Timeout of your Sql Stored Procedure execution, but I don't think you can do that with the SqlHelper class.

You'll need to go with the SqlCommand class, and set the timeout there.

这篇关于超时周期没有过去,但还是超时(见$ C $三)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆