我的插入存储过程工作,但我收到此错误ADODB.Recordset错误'800a0e78'

时间:2012-07-13 20:59:17

标签: asp-classic ado

该网站在帮助解决许多未知问题方面非常有用。谢谢。现在我有一个未知的,我无法找到答案。

错误是:

  

ADODB.Recordset错误'800a0e78'

     

关闭对象时不允许操作。

我正在使用:

  • ASP Classic
  • MS SQL Server 2000

在ASP中,“form”中有一个<textarea>来插入注释,当插入注释并按下提交按钮时,存储过程会将注释插入注释表datetimestamp中并添加注册用户。这正是它正在做的事情。此外,在ASP中有一个<table>,其中包含note,datetimestamp和logon用户以及其他先前的条目。这也正是它正在做的事情。

按下提交按钮时出现上述错误,当错误页面显示时按下浏览器后退按钮,然后刷新页面<textarea>被清除,注意,datetimetime和登录用户显示在<table>

ASP经典页面:

Dim rsAccountNote

<form name="Accountnote" method="post" action="/admin/xt_Accountnote.asp">


    <td>
    <b>Add Note:</b><br />
    <textarea type="text" name="notes" value="" rows="7" cols="43" style="resize: none;"></textarea><br />
    <input type="submit" value="Add new note"/>
</td>

<table>

<tr>    

    <td>
    <b>Read Notes:</b>
    </td>

</tr>

        <%

        set rsAccountNote = DBConn.Execute("SELECT AccountNotes, LogonUser_Id, dtAccountNotedatetime FROM AccountNotes WHERE AccountId = " & rsAccount("AccountId"))

        rsAccountNote.Sort="dtAccountNotedatetime DESC" 

        Do While Not rsAccountNote.EOF

        %>          

<tr>

    <td>
    Added &nbsp;<%=rsAccountNote("dtAccountNotedatetime")%> &nbsp;by &nbsp;<%=rsAccountNote("LogonUser_Id")%>
    </td>

</tr>

<tr>

    <td>
    <b>Note:&nbsp;</b> <%=rsAccountNote("AccountNotes")%>
    </td>

    </tr>

        <%

        rsAccountNote.MoveNext  

        Loop    

        Set rsAccountNote = Nothing

        %>

</tr>

    </td>
</tr>
</table>
</form>

ASP Classic xt_page:

<%

Dim rsAccount
Dim iAccount
Dim LogonUser_id
Dim AccountNotes

sSQL = "exec spApp_UpdateAccountNotes " & _
    "@iAccount = " & Trim(Request("Account_id")) & ", " & _
    "@AccountNotes = " & prepString(Request("AccountNotes")) & ", " & _
    "@LogonUser_id = " & prepString(Request("Logon_User"))
Call resultQuery(DBConn, rsAccount, sSQL, "", true)

    Response.Redirect("/Account_admin/accountinfo.asp?account_id=" & Trim(Request("account_id")))

%>

存储过程:

CREATE PROCEDURE spApp_UpdateAccountNotes
    (
    @iAccount int,
    @LogonUser_id varchar (50),
    @AccountNotes varchar(5000)
    )
AS

    SET NOCOUNT ON

    insert AccountNotes
        (
        AccountId,
        LogonUser_Id,
        AccountNotes
        )
    values
        (
        @iAccount,
        @LogonUser_Id,
        @AccountNotes
        )
GO

1 个答案:

答案 0 :(得分:1)

尝试使用Command对象将SP作为参数化查询执行。这解决了代码对SQL注入攻击开放的更严重问题。

实际上你的第一页也是开放的攻击,你也应该使用命令对象。

问题的真正根源可能是resultQuery尝试生成并使用SP中的记录集执行某些操作,该记录集不返回结果集,它只是一个插入。在这种情况下,resultQuery也许不是要调用的东西。只需要一个ADODB Command对象和Execute