且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

超时错误的SQL数据源

更新时间:2023-02-04 15:58:43

您可以增加超时属性类似这样

 保护无效SqlDataSource1_Selecting(对象发件人,SqlDataSourceSelectingEventArgs E)
{
e.Command.CommandTimeout = 0;
}



设置超时时间为0表示没有超时


Error code:

Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

Can someone provide me with code I can copy and paste so I can change the default timeout? I'm not sure where to put it into this code:

<head runat="server">
<title>Proxy Report</title>
</head>
<body>
<form id="form1" runat="server">
<div>

    <asp:Label ID="Label1" runat="server" Text="Proxy Report"></asp:Label>

</div>
<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1">
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
    ConnectionString="<%$ ConnectionStrings:ISALog1ConnectionString %>" 
    SelectCommand="ProxyReport" SelectCommandType="StoredProcedure">

</asp:SqlDataSource>
</form>
</body>
</html>

You can increase the Timeout property like this

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

Setting timeout to 0 means no timeout