Why am I getting unexpected error in ado with classic asp?

自古美人都是妖i 提交于 2020-01-07 05:34:27

问题


I have this (I have a connection above all this not shown):

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

As soon as I execute I get:

    Active Server Pages error 'ASP 0115' 
    Unexpected error 

    myasppage.asp 

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

I can't see what I am doing wrong. I tried various things such as remove prepared, but it has no effect (tried trial and error commenting out various above to no avail).

Oracle if it matters.

Thanks for help.


回答1:


try changing

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

to

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




回答2:


This is either permissions issue, or corrupted ADO drivers.

First, just to eliminate other stuff try this code for sake of debugging:

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

If you get same error, try:

  • Check permissions of IUSR account over database server, or use SQL Authentication.
  • Reinstall MDAC on the server to the latest version.

Also, what database? What IIS?




回答3:


I highly doubt this is the issue but it's the only thing I could see. It probably just the copy and paste but there is an extra space in this line of code. between .Append .Create

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


来源:https://stackoverflow.com/questions/8541281/why-am-i-getting-unexpected-error-in-ado-with-classic-asp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!