Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Object Closed error in VB6 for Oracle DB

Hi Everyone,
I am facing some weird problem here. I have a VB6 application in which I connect to different databases like SQL Server, Oracle, Sybase ASA. I send my application's executable to different users.
All users who ran the application on SQL Server and Sybase ASA (iSQL from iAnywhere), never reported a problem.
But users trying to run the same on Oracle always report that they are unable to use it. After going through the log file, the application outputs in case of an error, I found out that I am getting the 'Operation is not allowed when the object is closed' error. The code is given below
If i >= 12 And i <= 22 Then
rsRec.Open strQuery, dbConnection, adOpenStatic, adLockReadOnly, adCmdText
noofScripts = rsRec.RecordCount ' Error occurs in this line
XLWs.Cells(rowcount, colcount1) = noofScripts
If Not noofScripts = 0 Then
ReDim Preserve ScrptArray(ScrptCount + noofScripts)
ReDim Preserve ScrptIndices(ScrptCount + noofScripts)
rsRec.MoveFirst
Do While Not rsRec.EOF
ScrptArray(ScrptCount) = rsRec.Fields(0)
ScrptIndices(ScrptCount) = CStr(ls_EntityArray(i)) + " - " + CStr(ScrptCount)
rsRec.MoveNext
ScrptCount = ScrptCount + 1
Loop
End If
Else
rsRec.Open strQuery, dbConnection, adOpenForwardOnly, adLockReadOnly, adCmdText
If Not rsRec.EOF Then
XLWs.Cells(rowcount, colcount1) = rsRec.Fields(0)
End If
End If
rsRec.Close
The code runs perfectly well in other DBs. Only in case of Oracle it fails at the "noofScripts = rsRec.RecordCount" line. The noteworthy point here is the Db does not return any data. Is that a problem? If no records are returned, the RecordCount property should return zero - right? But why does it fail, that too only in case of Oracle?
Is there any setting that I need to do to the DSN used by the application to connect to the database?

Regards,
Satish
[2226 byte] By [SatishP] at [2007-11-11 10:14:21]