Asp.net C # SqlDataSource Schedule Problems

I am trying to increase the SqlDataSource timeout in 30 seconds (it seems by default). I am trying to start a stored procedure that should work through 100,000 records. During periods of employment, this time. I am using ASP.NET 4.0 and IIS 6.0 on a 2003 server.

Error message: Timeout. The wait period expires before the operation is completed or the server is not responding.

I tried to unsuccessfully extend the timeout:

< asp:SqlDataSource ID="dsTest" EnableCaching="true" CacheDuration="604800" runat="server" ConnectionString="<%$ ConnectionStrings:SuperNARIC %>" SelectCommand="selectStatus" SelectCommandType="StoredProcedure" onselecting="dsTest_Selecting" > <SelectParameters> < asp:ControlParameter ControlID="ddlCar" Name="CountryID" PropertyName="SelectedValue" Type="Int32" /> < /SelectParameters> < /asp:SqlDataSource> protected void dsTest_Selecting(object sender, SqlDataSourceSelectingEventArgs e) { e.Command.CommandTimeout = 300; } 

Any help would be greatly appreciated.

thanks

+6
source share
7 answers

There are two types of timeout: ConnectionTimeout and CommandTimeout :

ConnectionTimeout Determines the maximum timeout for your application to establish a connection to your server.

CommandTimeout : The maximum time to execute a command.

Make sure you set both options. In the Team :

  command.CommandTimeout = 300; 

Note. This can be implemented in the Selecting event if your command is part of a DataSource. e.command.CommandTimeout = 0; A value of 0 means endless waiting.

And the connection string :

 SqlConnectionStringBuilder cs = new SqlConnectionStringBuilder(connectionString); cs.ConnectTimeout = 300; 

Or:

 <add name="MyConnectionString" connectionString="Data Source=.\SQLEXPRESS; Database=MyDB; Integrated Security=True;Pooling=True;connection timeout=30" providerName="System.Data.SqlClient" /> 

Note Try setting the connection string timeout worldwide, possibly in your configuration file.

+9
source

As mentioned here , this worked for me.

You can increase the Timeout property as follows

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

Latency to 0 means no timeout

+5
source

The timeout is usually set in the connection string. See http://www.connectionstrings.com/ for more details.

+3
source

You need to make sure that both the CommandTimeout parameter and your ConnectionString Connect Timeout configured to exclude timings from lengthy stored procedures. If you do not set the connection timeout, you will close the time until the stored procedure completes, even if the stored procedure command itself has not been disabled.

+1
source

Connection timeout / Connection timeout / Timeout Default value - 15 seconds Duration (in seconds) of waiting for the connection to the server until the attempt is stopped and an error is generated. Valid values ​​are greater than or equal to 0 and less than or equal to 2147483647.

 string myconstr = "Data Source=(local);Initial Catalog=AdventureWorks;" + "Integrated Security=SSPI;Connection Timeout=30" 

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring(v = vs .100) .aspx

0
source

The maximum connection timeout value can be 2147483647. Try setting the connection timeout value to the connection string in the web configuration below:

<connectionStrings> <add name="ConnectionString" connectionString="Data Source=144681;Initial Catalog=Customer;Persist Security Info=True;User ID=xxxxx;Password=yyyyy" providerName="System.Data.SqlClient" /> </connectionStrings>

0
source

There is latency for SQL and page response time.

 Server.ScriptTimeout = 120; e.Command.CommandTimeout = 120; 
-1
source

Source: https://habr.com/ru/post/913971/


All Articles