1

我已经从对这个问题的其他一些回复中浏览并实施了代码,但我仍然没有运气。我仍然收到错误消息。

    If ((bReport And bIsDate And CheckPermissions("lotsales")) Or Request.QueryString("report")) Then
    OpenDB
    Dim oRs, sSQL, sSQL2, iCancellations, iSales, sDate, sInitDate, sEndDate, iPhaseID, iPhaseNumber, rowCount

    sInitDate = Request("startDate")
    sEndDate = Request("endDate")
    sSQL = "sp_get_lot_sales_test '" & sInitDate & "', '" & sEndDate & "', " & sPhase & ", '" & sReportView & "'"

    'response.write vbNewLine & "<!-- sql: " & sSQL & "-->" & vbNewLine
    'response.write sSQL
    'response.Flush
    Set oRs = ExecuteCommand(sSQL,1) 
End If

然后这是发生错误的地方 -

If (oRs.EOF) Then <-- fails here
       Response.Write("<TR><TD ALIGN=""center"">There is no data to report on!</TD></TR>")
    Else
        Do While Not oRs.EOF

作为最后的手段,我将回到存储过程并解构它以确保一切正常。有没有人知道为什么我可能会收到错误?我不会在任何地方发出关闭消息。

这是 ExecuteCommand 函数 -

Function ExecuteCommand(s,i)
    On Error Resume Next
    Set ExecuteCommand = oDBc.Execute(s, , i)
End Function
4

4 回答 4

17

这可能很旧,但我经常遇到该错误(关闭对象时不允许操作)。

我所做的是在存储过程中,我添加了以下内容:

设置无计数

设置 ANSI_WARNINGS 关闭

在过程中的AS正下方。

That's all I do and the problem goes away.

于 2013-05-17T20:35:22.997 回答
5

I am maintaining some old Classic ASP code for a client, code that we took over from a prior developer, and this bug drove me crazy for 4 hours.

I finally discovered a few PRINT statements in the associated SQL stored procedure, which were there for troubleshooting or checking values but don't actually return rows, yet they caused this to fail:

Set cnContentDB = Server.CreateObject("ADODB.Connection")
cnContentDB2.Open sString

sSQL = "EXEC YourStoredProc"

Set oRS2 = Server.CreateObject("ADODB.Recordset")
oRS2.Open sSQL, cnContentDB

if not oR2.EOF then   'THIS WAS GIVING THE ERROR,
                      'EVEN THOUGH THE STORED PROC ALWAYS RETURNS RECORDS

I removed the Print statements, and the error went away.

于 2015-02-02T23:45:39.153 回答
2

Although this is years old, we still end up here looking for solutions. The cause of this error for me was that the User did not have Execute permission on the Stored Procedure. Granting Execute permission resolved the error.

于 2019-11-20T23:08:08.280 回答
0

您需要一个连接对象。

set conn = server.CreateObject("adodb.connection")
set oRs = conn.execute(sSql)
于 2012-10-09T20:05:14.090 回答