Link to home
Start Free TrialLog in
Avatar of worship_me
worship_meFlag for Japan

asked on

[ADO] Disconnecting Recordsets executed by Command

How do you disconnect recordsets that were opened this way in ADO...

C++

_CommandPtr pCommand;
pCommand.CreateInstance(----);
pCommand->ActiveCommand = pConn;
....
_RecordsetPtr pRset;
pRset.CreateInstance(----);
pRset->CursorLocation = adUseClient;
pRset->Open(_variant_t((IDispatch*)pCommand),
           vtMissing, adOpenStatic,
           adLockBatchOptimistic, adCmdUnspecified);

VB

Dim command AS ADODB.Command
Dim recordset AS ADODB.Recordset

Set command = New ADODB.Command
command.ActiveConnection = conn
...
Set recordset = New ADODB.Recordset
recordset.open command,,adOpenStatic,
              adLockBatchOptimistic, adCmdUnspecified

How to set the ActiveConnection property of pRset to NULL or nothing. Do I use the command object that I opened it with?
SOLUTION
Avatar of manduz_griffus
manduz_griffus

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of worship_me

ASKER

but i still need to use my recordset...

Set recordset = New ADODB.Recordset
recordset.open command,,adOpenStatic,
           adLockBatchOptimistic, adCmdUnspecified
recordset.ActiveConnection = nothing

somehow this is not possible if recordset is opened with its Source property as a valid Command object.

anyway, thanks.
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ayufans
ayufans

No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

- Points split between emoreau and manduz_griffus

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

ayufans
Cleanup Volunteer