SQL超时解决方法
关键字: sql超时解决方法
在服务器端处理一些耗时很长的处理的时候,有时会遇到超时的情况。在无需发送响应到 IE 的时候,此问题无关大雅。但在需要处理完后发送响应的情况下,往往导致浏览器超时无响应。
由于生成统计表格需要很长时间,到下载的时候浏览器已超时。
解决:在统计时,同时打开一个请求下载的页面,这个页面会定时刷新,重复请求。在数据准备好的情况下,进行下载;未准备好的情况下,显示提示语。
总结:对于这种长时间的会导致浏览器超时的处理,可以先在服务器方处理完,然后用异步的方式(浏览器重复询问,异步通知等)方式来取得响应。
SQL超时解决方法
影响服务器产生超时的设置大致有:
1. Server.scrīpt
Timeout, 2. Connection对象的CommandTimeOut属性, 3. Command对象的CommandTimeOut属性, 4. IE浏览器的设置.
Server.scrīptTimeout,默认值是90秒. 要增大它,在你的asp文件中加一句,如下: Server.scrīptTimeout=999, 将页面超时设为999秒.
最初我只设置Server.scrīptTimeout, 但仍会出现timeout错误,无论它的值设成都多大. 后在社区里看到一帖子,提到commandTimeout属性, 于是查看Option Pack文档,果然还有其他的timeout.
Connection对象和Command对象都有个CommandTimeOut属性, 默认是30秒,如果你有一个耗时的查询或数据处理, 很容易就超时了.要增大它,也很容易,创建对象后, 设置它的属性,如下: con.CommandTimeOut = 999, 设为999秒,其中con是一Connection对象. 如设为零,将无限等待,没有这一timeout限制.
Command对象不会继承Connection的这一属性, 所以对可能超时的Command也要单独设置CommandTimeout属性.
最后IE也有个超时设置,5分钟从服务器得不到数据,也超时. 这种情况可能很少碰到, 但当我把一10多万查询的结果保存为mdb文件时, 就遇到了.(至于保存的方法,请参看精华区中的一篇帖子.)
如何设置浏览器超时时间 setTimeout('window.close()',100) 其中100为毫秒 。在onload上面加上上面这段代码,应该可以了 在HTML HEAD 中加 <meta http-equiv="REFRESH" content="900;url=TimeOut?OpenForm"> 900是15分钟时间。 TimeOut?OpenForm 是超时转到的页面
链接超时问题的浏览器端解决方案 How to change the default Keep-Alive Time-Out Value in IE View products that this article applies to. Warning If you use Registry Editor incorrectly, you may cause serious problems that may require you to reinstall your operating system. Microsoft cannot guarantee that you can solve problems that result from using Registry Editor incorrectly. Use Registry Editor at your own risk.
You may have to increase the default time-out value for persistent HTTP connections in Internet Explorer if you are using a Web program that must communicate with Internet Explorer over the same TCP/IP socket after one idle minute. To change the default time-out value for persistent HTTP connections in Internet Explorer, add a DWORD value that is named KeepAliveTimeout to the following registry key, and then set its value data to the time (in milliseconds) that you want Internet Explorer to wait before resetting an idle connection: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\InternetSettings To do this, follow these steps: 1. Click Start, click Run, type regedit, and then click OK. 2. Locate and then click the following key in the registry: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\InternetSettings 3. On the Edit menu, point to New, and then click DWORD Value. 4. Type KeepAliveTimeout, and then press ENTER. 5. On the Edit menu, click Modify. 6. Type the appropriate time-out value (in milliseconds), and then click OK. For example, to set the time-out value to two minutes, type 120000. 7. Restart Internet Explorer. If you set the KeepAliveTimeout value to less than 60,000 (one minute), you may have problems communicating with Web servers that require persistent HTTP connections. For example, you may receive a "Page cannot be displayed" error message.
If you must have a KeepAliveTimeout value higher than 120000 (two minutes), you must create an additional registry key and set its value equal to the KeepAliveTimeout value that you want. The additional registry key is ServerInfoTimeout. It is a DWORD with a value (in milliseconds) and in the same location as KeepAliveTimeout.
For example, to use a three-minute KeepAliveTimeout value, you must create the following registry keys: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\InternetSettings
KeepAliveTimeout DWORD value 180000 (in milliseconds) ServerInfoTimeout DWORD value 180000 (in milliseconds) By default, HTTP 1.1 is enabled in Internet Explorer except when you establish an HTTP connection through a proxy server. When HTTP 1.1 is enabled, HTTP connections remain open (or persistent) by default until the connection is idle for one minute or until the value that is specified by the KeepAliveTimeout value in the registry is reached. You can modify HTTP 1.1 settings in Internet Explorer by using the Advanced tab in the Internet Options dialog box.
|