M
Matt
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=us2"
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
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=us2"
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