Time Out Error in ASP.Net
How can I stop 开发者_运维问答time out error for executing SQL query in ASP.Net? I researched in Google but I couldn't solve my problem correctly.
I think your problem is about CommandTimeOut.The time (in seconds) to wait for the command to execute. The default is 30 seconds. Here is full example. Otherwise, you should set the ConnectionTimeOut in your database connection string. Something like that
<add key="ConnString2" value="Provider=SQLOLEDB;User Id=sa;PASSWORD=1;
SERVER=BlurBlur;database=BlurBlur;Connect Timeout=60;"/>
If you use the UpdatePanel, set the AsyncPostBackTimeout.
<asp:ScriptManager ID="ScriptManager1" runat="server"
AsyncPostBackTimeout ="360000"></asp:ScriptManager>
to be more sure
<httpRuntime executionTimeout="360000"/>
Please consider you have 2 timeout to deal with when you access database via ADO.net
ConnectionTimeout
set in connection string: it's the time in seconds asp.net will time out in opening a connection
and
CommandTimeout
es: SqlCommand cmd = new SqlCommand();
cmd.CommandTimeout = .....;
it's the time in seconds the sql command will timeout.
Stefano
精彩评论