FIX: Storing an ADO Recordset in GIT Might Cause An Access Violation (249175)
The information in this article applies to:
- ActiveX Data Objects (ADO) 2.1
- ActiveX Data Objects (ADO) 2.5
This article was previously published under Q249175 SYMPTOMS
The following paragraph is taken from the Microsoft Knowledge Base article 248287, "Understanding ADO Marshaling", which describes the potential problem of using the COM Global Interface Table with ActiveX Data Objects (ADO) Recordsets.
"COM provides a component called the Global Interface Table (GIT). The GIT allows an application to store a reference to an object's interface in the table so that the interface pointer can be retrieved at any time. When storing the interface pointer into the GIT, the object is queried for IMarshal and if IMarshal is exposed by the object, the marshaling data of the object is placed into a stream where it can be retrieved at some later time when the interface pointer is retrieved. IMarshal is exposed by the client cursor which actually does the passing of the recordset data. There is a problem if an open ADO Recordset object which uses adUseClient is placed into the GIT and then is later revoked from the table. An access violation will occur. To avoid the problem, place the Recordset's interface pointer into the GIT before calling Open on the Recordset. This will place the interface pointer into the GIT before the client cursor engine is invoked which will essentially cause standard marshaling to occur rather than record data being streamed from the cursor engine through
IMarshal. Only a pointer to the ADO Recordset's interface will be stored in this case which is the real intent of the programmer."
RESOLUTION
To avoid an access violation in your code you can either apply the hotfix listed in this article, or you can use one of the following workarounds:
- Do not use a client-side cursor.
-or-
- Store the recordset into GIT before you open the recordset.
NOTE: Because ADO disconnected recordsets require a client-side cursor, you cannot use the first workaround. However, the second workaround works if you are using ADO Recordset. Open() to open the recordset, but it will not work for the Connection. Execute() or Connection. OpenSchema() methods if the returned recordset is already open. In that case, the workaround is somewhat tricky.
If a call to an ADO method returns a recordset that is already open, you can use the following steps to work around the problem: - Persist the recordset object into a file or IPersistStream memory object. To persist an ADO recordset into a file, use the Recordset.Save() method. To persist an ADO recordset to IPersistStream, see the following article in the Microsoft Knowledge Base:
242249 Saving an ADO Recordset to an IStream
- Instantiate a new ADO Recordset object.
- Store the new recordset in GIT by using the RegisterInterfaceInGlobal() method.
- Load the new recordset object from the persisted data in step 1.
STATUSMicrosoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. This problem was corrected in MDAC 2.6. A supported hotfix is now available from Microsoft, but it is only intended to correct the problem that is described in this article. Only apply it to systems that are experiencing this specific problem. This hotfix may receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next Microsoft Data Access Components release that contains this hotfix. To resolve this problem immediately, contact Microsoft Product Support Services to obtain the fix. For a complete list of Microsoft Product Support Services phone numbers and information about support costs, visit the following Microsoft Web site: NOTE: In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The typical support costs will apply to additional support questions and issues that do not qualify for the specific update in question.
The English version of this fix should have the following file attributes or later:
Date Time Version Size File Name Platform
--------------------------------------------------------------------
05/04/2000 19:32 2.51.5303.1 327,952 Msadce.dll x86
05/03/2000 19:31 2.51.5303.0 487,696 Msado15.dll x86 REFERENCES- CLSID_StdGlobalInterfaceTable
- Global Interface Table
- Unhandled Exception
- R6025
- Pure Virtual Function Call
Modification Type: | Major | Last Reviewed: | 4/7/2006 |
---|
Keywords: | kbQFE KBHotfixServer kbADO260fix kbBug kbfix kbMDACNoSweep kbWin2000sp1Fix KB249175 |
---|
|