473,394 Members | 1,742 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Operation is not allowed when the object is closed

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

Mar 3 '06 #1
1 3994

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.

Mar 4 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Matthew Louden | last post by:
The following ASP code yields the following error, but actually the new record is stored in database. The same error happens when the application deletes a record, such as sqlStmt ="delete from...
1
by: cliverama | last post by:
help! fried brains.... asp calling a sqlserver7 stored proc which dynamically builds a sqlstatement & passes it to sp_executesql asp page gives the operation not allowed when object is closed...
17
by: James Baker | last post by:
I'm getting an error: "Operation is not allowed when the object is closed." on the lines of code below. I can't imagine why the object would be closed where it says it will be, I've just opened it...
1
by: | last post by:
So, I am getting this really annoying error.. the SQL Statement executes perfectly in Query Analyzer.. all I am doing is basically duplicating a row (insert into select from) from one table back...
2
by: Arpan | last post by:
An ASP application updates a SQL Server database table after a Form is submitted after which the user is directed to another page that should display the updated records. If the code is ...
1
by: amitbadgi | last post by:
Hello guys I am getting this error while converting an asp applicayion to asp.net Exception Details: System.Runtime.InteropServices.COMException: Operation is not allowed when the object is...
8
by: Jim in Arizona | last post by:
I've been using an example out of a book to be able to edit the rows in a database. I am getting the following error: ========================================================...
5
by: Sonasang | last post by:
Hi , I am creating a web page with ASP and Javascript.We have shared the foldres containg the code and all our team members are accessing the code. There is no problem for me when i run the...
4
rrocket
by: rrocket | last post by:
I am trying send information to the DB and the SP will return a recordset. The problem is that I keep getting this error (ADODB.Recordset error '800a0e78' Operation is not allowed when the object is...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.