Cloud Cloud - 1 year ago 139
SQL Question

Timeout Error for sql data source

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>
<form id="form1" runat="server">

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

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


Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download