Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ADODB.Recordset (0x800A0E78) Operation is not allowed when the object is closed.

1,596 views
Skip to first unread message

Shiller

unread,
Feb 21, 2008, 1:23:01 PM2/21/08
to
Experts,

I'm running a web application with Microsoft Access as my backend
database.

when I call a stored procedure from ASP I get the the following error
message:

Error Type:
ADODB.Recordset (0x800A0E78)
Operation is not allowed when the object is closed.

Has anyone else encounter this error message when running Access as
web database, if yes please help.

Thanks,

Shiller

Bob Barrows [MVP]

unread,
Feb 21, 2008, 1:48:39 PM2/21/08
to
This message is not dependant on the backend database. It's caused by
trying to do something that is not allowed. Exactly what that is in your
case is impossible for us to tell. Show us your code ... just the
relevant portion please: we don't need to see a bunch of html ...

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


Shiller

unread,
Feb 21, 2008, 2:04:47 PM2/21/08
to
On Feb 21, 1:48 pm, "Bob Barrows [MVP]" <reb01...@NOyahoo.SPAMcom>
wrote:

The error message is pointing to this line of code:

*****
If Not IsEmpty(mCountSQL) And Len(CountSQL) = 0 And NOT
DataSource.Recordset.EOF Then
*****

That code is found in the following function:

*****
Private Function DoOpen()
Dim Command
Dim builtSQL
Dim DataSource
Dim CountRecordset
Dim ResultRecordset
Dim CCSEventResult
Dim ParameterValue
Dim Parameter

Set DataSource = new clsDataSource
If IsObject(Connection) Then _
Set DataSource.Connection = Connection
Set DataSource.Command = Me

Select Case CommandType
Case dsTable, dsSQL
CCSEventResult = CCRaiseEvent(CCSEvents, "BeforeBuildSelect",
Me)
If InStr(SQL, "{SQL_Where}") > 0 Or
InStr(SQL,"{SQL_OrderBy}") > 0 Then
SQL = Replace(SQL, "{SQL_Where}", IIf(Len(Where) > 0, "
WHERE " & Where, ""))
If InStr(SQL,"{SQL_OrderBy}") > 0 Then
SQL = Replace(SQL, "{SQL_OrderBy}", IIf(Len(OrderBy) > 0,
" ORDER BY " & OrderBy, ""))
Else
SQL = SQL & IIf(Len(OrderBy) > 0, " ORDER BY " & OrderBy,
"")
End If
builtSQL = ParseParams(SQL, WhereParameters)
Else
builtSQL = ParseParams(SQL & IIf(Len(Where) > 0, " WHERE " &
Where, "") & IIf(Len(OrderBy) > 0, " ORDER BY " & OrderBy, ""),
WhereParameters)
End If
CCSEventResult = CCRaiseEvent(CCSEvents,
"BeforeExecuteSelect", Me)
Set DataSource.Recordset = OpenRecordset(builtSQL,False)
If ActivePage > 0 And IsNeedMoveToPage Then
DataSource.MoveToPage ActivePage
End If
If Not IsEmpty(mCountSQL) And Len(CountSQL) = 0 And NOT
DataSource.Recordset.EOF Then
If DataSource.Recordset.State = adStateOpen Then
Dim Counter : Counter = 0
While NOT DataSource.Recordset.EOF AND Counter < mPageSize
+1
Counter = Counter + 1
DataSource.Recordset.MoveNext
Wend
DataSource.RecordCount = IIF(ActivePage>0,(ActivePage - 1)
* mPageSize, 0) + Counter
End If
If ActivePage > 0 Then
DataSource.Recordset.MoveFirst
DataSource.MoveToPage ActivePage
End If
End If


CCSEventResult = CCRaiseEvent(CCSEvents, "AfterExecuteSelect",
Me)
If Errors.Count > 0 Then
DataSource.Errors.AddErrors Errors
End If
Set DoOpen = DataSource

Case dsProcedure
CCSEventResult = CCRaiseEvent(CCSEvents, "BeforeBuildSelect",
Me)
Set Command = CreateSP()
CCSEventResult = CCRaiseEvent(CCSEvents,
"BeforeExecuteSelect", Me)
Set DataSource.Recordset = Connection.Execute(Command)
If Connection.Errors.Count > 0 Then
Errors.AddErrors Connection.Errors
End If

If IsArray(CommandParameters) Then
For I = 0 To UBound(CommandParameters)
If IsArray(CommandParameters(I)) Then
If CommandParameters(I)(3)=adParamInputOutput Or _
CommandParameters(I)(3)=adParamOutput Or _
CommandParameters(I)(3)=adParamReturnValue Then
DataSource.HasOutPutParameters = True
Exit For
End If
End If
Next

If Connection.Database = "MSSQLServer" Then
If DataSource.HasOutPutParameters Then
While (Not DataSource.Recordset is Nothing)
Set
DataSource.Recordset=DataSource.Recordset.NextRecordset
Wend
End If
End If

For I = 0 To UBound(CommandParameters)
If IsArray(CommandParameters(I)) Then
If CommandParameters(I)(3)=adParamInputOutput Or _
CommandParameters(I)(3)=adParamOutput Or _
CommandParameters(I)(3)=adParamReturnValue Then
Parameters.ParameterSources(CommandParameters(I)
(1))=Command.Parameters(CommandParameters(I)(0))
DataSource.HasOutPutParameters = True
End If
End If
Next

If Connection.Database = "MSSQLServer" Then
If DataSource.HasOutPutParameters Then
Set DataSource.Recordset = Connection.Execute(Command)
End If
End If
End If

If ActivePage > 0 Then
DataSource.MoveToPage ActivePage
End If

If DataSource.Recordset.State > 0 Then
Dim TempNumber : TempNumber = 0
Do While TempNumber <> RecordsetNumber
Set DataSource.Recordset =
DataSource.Recordset.NextRecordset
If DataSource.Recordset is Nothing Then
DataSource.Errors.AddError("wrong RecordsetNumber")
Exit Do
End If
TempNumber = TempNumber + 1
Loop
End If

CCSEventResult = CCRaiseEvent(CCSEvents, "AfterExecuteSelect",
Me)
If Connection.Errors.Count > 0 Then
DataSource.Errors.AddErrors Errors
End If

Set Command = Nothing
Set DoOpen = DataSource

Case dsListOfValues
Dim I
CCSEventResult = CCRaiseEvent(CCSEvents, "BeforeBuildSelect",
Me)
Set DataSource.Recordset = CreateObject("ADODB.Recordset")
DataSource.Recordset.Fields.Append "bound", adBSTR, 256,
adFldCacheDeferred + adFldUpdatable
DataSource.Recordset.Fields.Append "text", adBSTR, 256,
adFldCacheDeferred + adFldUpdatable
CCSEventResult = CCRaiseEvent(CCSEvents,
"BeforeExecuteSelect", Me)
DataSource.Recordset.Open
For I = 0 To UBound(mLOV(0))
DataSource.Recordset.AddNew
DataSource.Recordset.Fields("bound").Value = mLOV(0)(I)
DataSource.Recordset.Fields("text").Value = mLOV(1)(I)
Next
DataSource.Recordset.Update
DataSource.Recordset.MoveFirst
CCSEventResult = CCRaiseEvent(CCSEvents, "AfterExecuteSelect",
Me)
Set DoOpen = DataSource
End Select
End Function

Bob Barrows [MVP]

unread,
Feb 21, 2008, 2:21:04 PM2/21/08
to
Shiller wrote:
> On Feb 21, 1:48 pm, "Bob Barrows [MVP]" <reb01...@NOyahoo.SPAMcom>
> wrote:
>> Shiller wrote:
>>> Experts,
>>
>>> I'm running a web application with Microsoft Access as my backend
>>> database.
>>
>>> when I call a stored procedure from ASP I get the the following
>>> error message:
>>
>>> Error Type:
>>> ADODB.Recordset (0x800A0E78)
>>> Operation is not allowed when the object is closed.
>>
>>> Has anyone else encounter this error message when running Access as
>>> web database, if yes please help.
>>
>> This message is not dependant on the backend database. It's caused by
>> trying to do something that is not allowed. Exactly what that is in
>> your case is impossible for us to tell. Show us your code ... just
>> the relevant portion please: we don't need to see a bunch of html ...
>>
> The error message is pointing to this line of code:
>
> *****
> If Not IsEmpty(mCountSQL) And Len(CountSQL) = 0 And NOT
> DataSource.Recordset.EOF Then
> *****
>

Well, it looks to me as if you are trying to check the EOF property of a
closed recordset. Looking in your code I see that this line is followed
by:


If DataSource.Recordset.State = adStateOpen Then

It seems to me that you should be doing this BEFORE checking EOF ...

sagargo...@gmail.com

unread,
Apr 5, 2020, 5:33:53 AM4/5/20
to
yes you are right. this is happening with me also actually i think crystal report created on recordset basis when we close connection recordset automatically closed that is why it generate problems
0 new messages