服务器上的网站出错了,出错信息如下:
Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.
以前没出现过这种错误,最近老出现,重启IIS,或者回收进程,或者等一段时间就好了
哪位大侠遇过这样的问题,望赐教,先谢了。
我都快郁闷死了

解决方案 »

  1.   

    环境:.net2.0+sql 2000 数据也不是太多,2,3万条而已
      

  2.   

    优化SQL查询语句,可用SQL Profiler跟踪那些执行时间过长的语句,然后进行优化。
      

  3.   

    用SQL Profiler看了下,有起始时间和结束时间的,Duration都 是0
    没有发现有长时间执行的SQL语句
      

  4.   

    SqlConnection.ConnectionTimeout 默认为 15 秒。
    SqlCommand.CommandTimeout 默认为 30 秒。
    通过设置这俩个属性的值 
    http://www.cnblogs.com/samurai/archive/2008/12/08/1350429.html
    参考
      

  5.   

    给你看一段代码的例子吧,就是使用using语句保证数据库连接得到关闭。/// <summary>
        /// 对数据库执行增删改操作
        /// </summary>
        /// <param name="sql">要执行的SQL语句</param>
        /// <param name="commandType">要执行的查询语句的类型,如存储过程或者SQL文本命令</param>
        /// <param name="parameters">Transact-SQL 语句或存储过程的参数数组</param>
        /// <returns></returns>
        public int ExecuteNonQuery(string sql,CommandType commandType, SqlParameter[] parameters)
        {
            int count = 0;
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                using (SqlCommand command = new SqlCommand(sql, connection))
                {
                    command.CommandType = commandType;//设置command的CommandType为指定的CommandType
                    //如果同时传入了参数,则添加这些参数
                    if (parameters != null)
                    {
                        foreach (SqlParameter parameter in parameters)
                        {
                            command.Parameters.Add(parameter);
                        }
                    }
                    connection.Open();//打开数据库连接
                    count = command.ExecuteNonQuery();
                }
            }
            return count;//返回执行增删改操作之后,数据库中受影响的行数
        }
      

  6.   

    将你的站点设置允许匿名访问即可 
    引用:
    Server Application Error详细解决办法
    这个问题真的很麻烦,我差点重装系统,我今天偶然发现:
    打开Internet 信息服务设置--控制面板--管理工具--Internet 信息服务--网站--在你设置的站点上点鼠标右键,点击属性,在主目录一栏,在应用程序保护中选择:低IIs保护即可。
    遇到这个问题的朋友不妨试一下
    一、现象描述:
    本地运行asp文件,IE提示:Server Application Error 
    The server has encountered an error while loading an application during the processing of your request. Please refer to the event log for more detail information. Please contact the server administrator for assistance. 查看日志文件:系统日志具体描述如下: DCOM 错误 无 10010 NT AUTHORITY\SYSTEM Myserver 服务器 {3D14228D-FBE1-11D0-995D-00C04FD919C1} 没有在限定的时间内用 DCOM 注册。 W3SVC 警告 无 36 N/A Myserver 服务器未能转入应用程序 '/LM/W3SVC/1/Root'。错误是 '服务器运行失败 '。 
    若要获取关于此消息的更多的信息,请访问 Microsoft 联机支持站点: http://www.microsoft.com/contentredirect.asp 。 应用程序日志具体描述如下: COM+ 错误 管理 4205 N/A Myserver 由于在下列系统 API 错误,COM+ 服务无法初始化。它通常是由本地计算机的系统资源存储问题引起的。 
    CryptAcquireContext 
    进程名称: dllhost.exe 
    该错误的严重性已导致进程终止。 
    错误代码= 0x80090017 : 提供程序类型未被定义。 
    COM+ 服务内部信息: 
    文件: .\security.cpp, 行: 617 二、原因分析曾经删除过SA,SAM文件是保存用户密码的数据库文件,删除后,所有的用户信息就会丢失,而相应的组信息也会随之丢失,虽然重新登录过系统,系统已经重新建立了SAM文件,也重新安装了IIS,IWAM帐号也已经重新建立,但是,原用户组中的特殊信息却没有被恢复。检查“开始”->“设置”->“控制面板”->“管理工具”->“组件服务”中,“控制台根目录”->“组件服务”->“计算机”->“我的电脑”->“COM+应用程序”中,有一个IIS Out-Of-Process Pooled Applications该应用程序的ID号即为{3D14228D-FBE1-11D0-995D-00C04FD919C1},很多系统报错找不到应用程序{3D14228D-FBE1-11D0-995D-00 
    C04FD919C1}之类的错误,就是因为该应用程序未能启动,打开该应用程序的属性,检查标识却为IWAM用户,右键启动,报错。改为管理员后,可正常启动。把IWAM加入本地管理员组中,也可正常启动。确定是因为IWAM用户无权访问该应用程序所致。 三、解决办法
    1、修改IWAM_Myserver帐号密码,在“开始”->“设置”->“控制面板”->“管理工具”->“计算机管理”中,“系统工具”->“本地用户和组”->“用户”里面,一个IWAM_Myserver(Myserver为本地计算机名)的帐号内,右键更改密码,更改为一个自定义的密码即可,假设为“1234”; 2、修改IIS内部IWAM_Myserver帐号密码,在c:\inetpub\adminscripts\目录下(IIS安装默认目录),输入:c:\inetpub\adminscripts>cscript.exe adsutil.vbs set w3svc/wamuserpass "1234" .修改成功后,系统有如下提示wamuserpass: (string) "******" 也可以修改相关文件使查看到的******变为可显示:
    在c:\inetpub\adminscripts 找到adsutil.vbs (根据装系统时设定的不同,有的路径可能不一样)
    用记事本打开此文件
    查找 issecureproperty = true (只有一个符合字段,在一个条件语句里面)
    将 issecureproperty = true 改为 issecureproperty = false
    保存关闭。
    然后使用命令:cscript.exe adsutil.vbs get w3svc/wamuserpass来获取密码3、在“开始”->“设置”->“控制面板”->“管理工具”->“计算机管理”中,“系统工具”->“本地用户和组”->“用户”里面,确认IWAM_My server用户只在GUEST组内,再在“本地用户和组”->“组”里面,右键点击Users组属性,添加进NT AUTHORITY\Authenticated Users和NT AUTHORITY\Interactive两个用户成员,确定。 4、在IIS安装默认目录下输入:c:\inetpub\adminscripts>cscript.exe synciwam.vbs -v 
    将COM+程序的用户改回为IWAM用户,重新启动IIS Out-Of-Process Pooled Applications应用程序,没有再报错了,再重启IIS,检查所有WEB站点服务,故障现象解除!
    Server Application Error解决
    在浏览器中: HTTP 500 - Internal Server Error 
    - 或 - Server Application Error
    The server has encountered an error while loading an application during the processing of your request.Please refer to the event log for more detail information.Please contact the server administrator for assistance. 
    在系统事件日志中: SourceCOM
    ErrorCOM got error "Logon Failure:unknown username or bad password" Unable to logon .\IWAM_SERVERNAME in order to run the server. 
    - 和 - Source:W3SVC
    Error:"The server failed to load application '/LM/W3SVC/1/Root/op.'The error was 'The server process could not be started because the configured identity is incorrect.Check the username and password. 
    - 或 - Source:W3SVC Error:"The server failed to load application '/LM/W3SVC/4/Root'.The error was 'c000003b'." 
    - 和 - Source:W3SVC Error:"The COM Application '{3D14228D-FBE1-11d0-995D-00C04FD919C1}' at '/LM/W3SVC/4/Root' failed to activate out of process." 
    比较简单的解决办法:在计算机用户管理中删除启动iis及来宾账号,重装一次IIS即可
      

  7.   

    这可能是由于 SQL 配置参数打开数据库被设置得太低,(20 SQL Server 6.0 版的默认设置)。 如果您缓慢将数据库添加到在 SQL 系统,并且最后超过了配置的值,您可能会不生成记录到 SQL 任何"Out of 打开的数据库"消息。 增加 SQL 配置参数打开数据库可能会解决此问题。 有关将此参数设置更多信息请查阅 Microsoft SQL 管理员助理"。
      

  8.   

    我这个和你给的参考不一样,这个是服务器超时没有响应,你给的参考是连接数不够而产生的超时
    The timeout period elapsed prior to completion of the operation or the server is not responding.
      

  9.   

    访问我的博客 程序员日记 http://www.ideaext.com