【问题标题】:Why am I getting unexpected error in ado with classic asp?为什么我在使用经典 asp 时遇到意外错误?
【发布时间】:2011-12-18 16:50:21
【问题描述】:

我有这个(我有一个没有显示的连接):

Set cmd = Server.CreateObject("ADODB.Command")
Set cmd.ActiveConnection = conn
cmd.CommandType = 1
cmd.Parameters.Append .CreateParameter("LASTNAME", 200, 1, 50, "JONES")
cmd.CommandText = "select * from employees where lastname = ?"
cmd.Prepared = True
Set rs = cmd.Execute

我一执行就得到:

    Active Server Pages error 'ASP 0115' 
    Unexpected error 

    myasppage.asp 

    A trappable error (C0000005) occurred in an external object. 
The script cannot continue running.

我看不出我做错了什么。我尝试了各种方法,例如删除准备好的,但它没有效果(尝试反复尝试注释掉上述各种无济于事)。

Oracle 如果重要的话。

感谢您的帮助。

【问题讨论】:

  • 你为什么对记录集使用命令,为什么不使用 Adodb.Recordset?
  • 如果我需要记录集并使用命令,我会使用存储过程。

标签: asp-classic ado


【解决方案1】:

尝试改变

cmd.Parameters.Append .CreateParameter("LASTNAME", 200, 1, 50, "JONES")

cmd.Parameters.Append cmd.CreateParameter("@lastname", 200, 1, 50, "JONES")

【讨论】:

  • "LASTNAME""@lastname" 不会有什么不同,但重要的部分是 cmd.CreateParameter
【解决方案2】:

这要么是权限问题,要么是 ADO 驱动程序损坏。

首先,为了消除其他东西,试试这个代码以便调试:

Set rs = conn.Execute("select * from employees where lastname = 'JONES'")

如果您遇到同样的错误,请尝试:

  • 检查 IUSR 帐户对数据库服务器的权限,或使用 SQL 身份验证。
  • 在服务器上重新安装 MDAC 到最新版本。

另外,什么数据库?什么 IIS?

【讨论】:

    【解决方案3】:

    我非常怀疑这是问题所在,但这是我唯一能看到的。它可能只是复制和粘贴,但在这行代码中有一个额外的空间。在 .Append.Create

    之间
     `cmd.Parameters.Append .CreateParameter("LASTNAME", 200, 1, 50, "JONES")`
    

    【讨论】:

    • 信不信由你,从我能找到的所有东西中它都应该在那里。我也觉得它看起来很奇怪。
    猜你喜欢
    • 2021-12-07
    • 2020-06-01
    • 2015-03-16
    • 2021-03-10
    • 1970-01-01
    • 2011-10-28
    • 1970-01-01
    • 2019-01-16
    • 2019-09-19
    相关资源
    最近更新 更多