?
Solved

[ADO] Disconnecting Recordsets executed by Command

Posted on 2003-03-02
4
Medium Priority
?
366 Views
Last Modified: 2013-12-25
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
Comment
Question by:worship_me
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 

Assisted Solution

by:manduz_griffus
manduz_griffus earned 100 total points
ID: 8055390
recordset.close

set recordset = nothing
set conn = nothing

this works in vb
0
 

Author Comment

by:worship_me
ID: 8055477
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
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 100 total points
ID: 8056630
set recordset.ActiveConnection = nothing
0
 
LVL 1

Expert Comment

by:ayufans
ID: 9221793
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question