简体   繁体   English

等待操作超时-延长超时时间

[英]The wait operation timed out - Lengthen Timeout Period

I have a grid view that is populated on a button click event: 我有一个在按钮单击事件中填充的网格视图:

    <asp:GridView CssClass="hoursGrid" ID="hoursReportGridView" runat="server" AutoGenerateColumns="False" BackColor="#DEBA84" BorderColor="#DEBA84"
        BorderStyle="None" BorderWidth="1px" CellPadding="3" CellSpacing="2" DataSourceID="SqlDataSource2" OnRowDataBound="hoursReportGridView_OnRowDataBound" DataKeyNames="DifferentUsers, DoubleBookedFlag, PointPerson, Person">
        <Columns>
            <asp:BoundField DataField="Person" HeaderText="Person" SortExpression="Project" />
            <asp:BoundField DataField="Project" HeaderText="Project" SortExpression="Project" />
            <asp:BoundField DataField="ProjectType" HeaderText="Project Type" ReadOnly="True" SortExpression="Sprint" ItemStyle-HorizontalAlign="Center" />
            <asp:BoundField DataField="Theme" HeaderText="Theme" ReadOnly="True" SortExpression="Theme" ItemStyle-HorizontalAlign="Center" />
            <asp:BoundField DataField="StoryNumber" HeaderText="Story Number" SortExpression="Story" ItemStyle-Width="6%" ItemStyle-HorizontalAlign="Center" />
            <asp:BoundField DataField="StoryTitle" HeaderText="Story Title" SortExpression="Story" ItemStyle-Width="20%" />
            <asp:BoundField DataField="Effort" HeaderText="Effort" SortExpression="Effort" ItemStyle-HorizontalAlign="Right" />
            <asp:BoundField DataField="Task" HeaderText="Task" SortExpression="Task"  ItemStyle-Width="20%" HtmlEncode="false" />
            <asp:BoundField DataField="OriginalEstimateHours" HeaderText="Original Estimate" SortExpression="OriginalEstimateHours" ItemStyle-HorizontalAlign="Right" />
            <asp:BoundField DataField="Monday" HeaderText="Mon" ReadOnly="True" SortExpression="Monday" ItemStyle-HorizontalAlign="Right" />
            <asp:BoundField DataField="Tuesday" HeaderText="Tues" ReadOnly="True" SortExpression="Tuesday" ItemStyle-HorizontalAlign="Right" />
            <asp:BoundField DataField="Wednesday" HeaderText="Wed" ReadOnly="True" SortExpression="Wednesday" ItemStyle-HorizontalAlign="Right" />
            <asp:BoundField DataField="Thursday" HeaderText="Thurs" ReadOnly="True" SortExpression="Thursday" ItemStyle-HorizontalAlign="Right" />
            <asp:BoundField DataField="Friday" HeaderText="Fri" ReadOnly="True" SortExpression="Friday" ItemStyle-HorizontalAlign="Right" />
            <asp:BoundField DataField="Saturday" HeaderText="Sat" ReadOnly="True" SortExpression="Saturday" ItemStyle-HorizontalAlign="Right" />
            <asp:BoundField DataField="Sunday" HeaderText="Sun" ReadOnly="True" SortExpression="Sunday" ItemStyle-HorizontalAlign="Right" />
            <asp:TemplateField HeaderText="Total" ItemStyle-HorizontalAlign="Right">
            <ItemTemplate>
                 <asp:LinkButton ID="taskLinkButton" Text='<%# Eval("Total") %>' Enabled='<%# Eval("StoryTitle").ToString() != "" %>' runat="server" OnClick="taskLinkButton_Click" />
            </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>

C#: C#:

private void generateReport()
{
    //set sql parameters
    SqlDataSource2.SelectParameters["userParam"].DefaultValue = currentEntity;
    SqlDataSource2.SelectParameters["startDateParam"].DefaultValue = startingDay.ToString();
    SqlDataSource2.SelectParameters["endDateParam"].DefaultValue = endingDay.ToString();
    SqlDataSource2.SelectParameters["orgTeamPK"].DefaultValue = orgTeam;
    SqlDataSource2.SelectParameters["productId"].DefaultValue = productId;
    SqlDataSource2.SelectParameters["theme"].DefaultValue = themeSelected;
    hoursReportGridView.DataBind();
}

The query can take up to 45 seconds in SSMS and is resulting in the website crashing: 在SSMS中,查询最多可能需要45秒,导致网站崩溃:

The wait operation timed out 等待操作超时

Description: An unhandled exception occurred during the execution of the current web request. 说明:执行当前Web请求期间发生未处理的异常。 Please review the stack trace for more information about the error and where it originated in the code. 请查看堆栈跟踪,以获取有关错误及其在代码中起源的更多信息。

Exception Details: System.ComponentModel.Win32Exception: The wait operation timed out 异常详细信息:System.ComponentModel.Win32Exception:等待操作超时

Until a more efficient query can be created, is it possible to make the timeout period longer so that the program wont crash? 在创建更有效的查询之前,是否可以延长超时时间,以使程序不会崩溃?

You could increase the CommandTimeout property. 您可以增加CommandTimeout属性。 Add the OnSelecting event handler of your SqlDataSource , and in your code behind add the following: 添加SqlDataSourceOnSelecting事件处理程序,并在后面的代码中添加以下内容:

protected void SqlDataSource2_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
    e.Command.CommandTimeout = 60;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM