I have been running into errors with ADO objects not being closed correctly
when the Close method is used in VDF. Here is an example procedure I wrote
to demonstrate the issue. The procedure just selects a project from a
Primavera table, then pops up an info_box with the value of the first
record:

Procedure Test
Handle hConnection hRecordSet hField hFields
String sResult
Variant vField vFields
Get Create U_cComConnection to hConnection
Send CreateComObject of hConnection
Send ComOpen of hConnection "DSN=Primavera SDK" "user" "pass"
OLEadConnectUnspecified
Get Create U_cComRecordSet to hRecordSet
Send CreateComObject of hRecordSet
Send ComOpen of hRecordSet "SELECT proj_short_name FROM Project, Projwbs
WHERE (Project.Proj_id = Projwbs.Proj_ID) AND (Projwbs.node_type =
'PROJECT')" (pvComObject(hConnection)) ;
OLEadOpenForwardOnly OLEadLockReadOnly OLEadCmdText
Get ComFields of hRecordSet to vFields
Get Create U_cComFields to hFields
Set pvComObject of hFields to vFields
Get ComItem of hFields "proj_name" to vField
Get Create U_cComField to hField
Set pvComObject of hField to vField
Get ComValue of hField to sResult
Send ComClose of hRecordSet
Send ReleaseComObject of hRecordSet
Send Destroy of hRecordSet
Send ComClose of hConnection
Send ReleaseComObject of hConnection
Send Destroy of hConnection
Send Info_box sResult
End_Procedure // Test

Send Test
Send Test

The first time through, there are no problems. The second time the procedure
is sent, the line Send ComOpen of hConnection... generates error 4399 saying
the object was already open. If I check the state property of the connection
object just prior to sending ComOpen, the result is 0 (adStateClosed).

I wrote this same basic thing in VBScript to see if it was a problem
somewhere with the drivers:

Dim connection
Dim rs
Const adOpenForwardOnly = 0
Const adLockReadOnly = 1

Set connection = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")

connection.Open "DSN=Primavera SDK;Uid=user;Pwd=pass"
rs.Open "SELECT proj_short_name FROM Project, Projwbs WHERE (Project.Proj_id
= Projwbs.Proj_ID) AND (Projwbs.node_type = 'PROJECT')", _
connection, adOpenForwardOnly, adLockReadOnly
Wscript.Echo rs.Fields.Item("proj_short_name").Value
rs.Close
connection.Close

connection.Open "DSN=Primavera SDK;Uid=user;Pwd=pass"
rs.CursorLocation = adUseClient
rs.Open "SELECT proj_short_name FROM Project, Projwbs WHERE (Project.Proj_id
= Projwbs.Proj_ID) AND (Projwbs.node_type = 'PROJECT')", _
connection, adOpenForwardOnly, adLockReadOnly
Wscript.Echo rs.Fields.Item("proj_short_name").Value
rs.Close
connection.Close

The VBScript runs correctly and generates no errors. I have duplicated the
same behavior using MSADO 2.1 and 2.7.

Has anyone else experienced any similar issues, or does anyone have any
suggestions how I might try to work around the problem?