• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 372
  • Last Modified:

[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?
0
worship_me
Asked:
worship_me
2 Solutions
 
manduz_griffusCommented:
recordset.close

set recordset = nothing
set conn = nothing

this works in vb
0
 
worship_meAuthor Commented:
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.
0
 
Éric MoreauSenior .Net ConsultantCommented:
set recordset.ActiveConnection = nothing
0
 
ayufansCommented:
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
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now