【问题标题】:ADODB CommandTimeout executing stored procedure in classic aspADODB CommandTimeout 在经典 asp 中执行存储过程
【发布时间】:2016-12-22 19:13:41
【问题描述】:

我在一个非常古老的项目中遇到了问题。长时间数据库进程出现超时异常。

这是初始代码

Set objCmd = Server.CreateObject("ADODB.Command")
objCmd.ActiveConnection = Common_CnxStr
objCmd.CommandText = "Db.SP_Name"
objCmd.CommandType = adCmdStoredProc
/*some query parameters are added here*/  
objCmd.Execute

这会运行 90 秒,然后因超时异常而失败。如何将超时时间增加到例如 5 分钟。

我尝试通过在我的代码中添加 objCmd.CommandTimeout 行来延长超时时间

Set objCmd = Server.CreateObject("ADODB.Command")
objCmd.CommandTimeout = 300 
objCmd.ActiveConnection = Common_CnxStr
objCmd.CommandText = "Db.SP_Name"
objCmd.CommandType = adCmdStoredProc
/*some query parameters are added here*/  
objCmd.Execute

但这不起作用,90 秒后我仍然有异常。我什至试着这样做

Server.ScriptTimeout = 300
Set objCmd = Server.CreateObject("ADODB.Command")
objCmd.CommandTimeout = 300 
objCmd.ActiveConnection = Common_CnxStr
objCmd.ActiveConnection.CommandTimeout = 300
objCmd.CommandText = "Db.SP_Name"
objCmd.CommandType = adCmdStoredProc
/*some query parameters are added here*/  
objCmd.Execute

但这并没有改变任何东西。请帮忙。

【问题讨论】:

  • 你能发布确切的错误信息吗?这可能是由于 Server.ScriptTimeout 而不是 ADODB 超时! "ASP 脚本超时的 Internet 信息服务 (IIS) 默认设置为 90 秒。"

标签: asp-classic ado


【解决方案1】:

尝试在你的 ASP 代码的开头添加这个:

<%
  Server.ScriptTimeout = 300 ' 5 minutes!
%>

无论如何,如果是性能问题,您应该让 DBA 改为检查 DB

另请参阅: https://technet.microsoft.com/en-us/library/bb632464.aspx

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-01
    相关资源
    最近更新 更多