Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Operation is not allowed when the object is closed

Reply
Thread Tools

Operation is not allowed when the object is closed

 
 
Matt
Guest
Posts: n/a
 
      03-03-2006
Got this problem that killing me...what am i doing wrong with this old
dll. When i call the function from asp i get "Operation is not allowed
when object is closed"
any clue will be appriciated....

test .asp
<%
dim oObj
dim a
set oObj= server.CreateObject("MyDll.MyClass")

a = oObj.MyFunc()
Response.write a
%>

--------------declaration
Const Conn As String = "Provider=SQLOLEDB;Data
Source=MySource;Database=MyDataBase;UID=us1;PWD=us 2"
Private m_objcontext As ObjectContext
Private Sql As String

-------------------

Public Function MyFunc() As Boolean

Dim oRs As ADODB.Recordset
On Error GoTo ErrorHandler:

vSql = "Select flag from flag_table"

Set oRs = New ADODB.Recordset

With oRs
.ActiveConnection = Conn
.CursorLocation = adUseServer
.CacheSize = 1
.Open Sql, , adOpenForwardOnly, adLockReadOnly
End With

If (Not oRs.EOF) And oRs.Fields("flag").Value = "Y" Then
MyFunc= True
Else
MyFunc= False
End If
oRs.Close
Set oRs = Nothing
m_objcontext.SetComplete
Exit Function
ErrorHandler:
If IsObject(oRs) Then
oRs.Close
Set oRs = Nothing
End If
m_objcontext.SetAbort
Err.Raise 21505, "blah", "blah- " & Err.Description
End Function

 
Reply With Quote
 
 
 
 
Anthony Jones
Guest
Posts: n/a
 
      03-04-2006

>
> Public Function MyFunc() As Boolean
>
> Dim oRs As ADODB.Recordset
> On Error GoTo ErrorHandler:
>
> vSql = "Select flag from flag_table"
>
> Set oRs = New ADODB.Recordset
>
> With oRs
> .ActiveConnection = Conn
> .CursorLocation = adUseServer
> .CacheSize = 1
> .Open Sql, , adOpenForwardOnly, adLockReadOnly
> End With
>
> If (Not oRs.EOF) And oRs.Fields("flag").Value = "Y" Then
> MyFunc= True
> Else
> MyFunc= False
> End If
> oRs.Close
> Set oRs = Nothing
> m_objcontext.SetComplete
> Exit Function
> ErrorHandler:
> If IsObject(oRs) Then
> oRs.Close
> Set oRs = Nothing
> End If
> m_objcontext.SetAbort
> Err.Raise 21505, "blah", "blah- " & Err.Description
> End Function


this line is causing the problem:-

If (Not oRs.EOF) And oRs.Fields("flag").Value = "Y" Then

Even though Not(EOF) may be false the expression Fields("flag").Value is
still evaluated resulting in an error (VB does not shortcut).

Use:-

If (Not oRs.EOF) Then
If oRs.Fields("flag").Value = "Y" Then

Anthony.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
asp to asp.net operation not allowed when object is closed amitbadgi@gmail.com ASP .Net 1 08-10-2005 11:36 AM
"operation is not allowed when the object is closed" error when using VBA online help -- Resolution TC ASP General 1 01-12-2005 09:05 AM
Operation is not allowed when the object is closed. ASP General 1 12-20-2004 04:51 PM
sp_executesql Operation is not allowed when the object is closed cliverama ASP General 1 11-05-2003 01:03 PM
Error "Operation is not allowed when the object is closed" Matthew Louden ASP General 6 09-28-2003 02:26 AM



Advertisments