BUG: WillChangeRecordset Event Not Executed
ID: Q191455
|
The information in this article applies to:
-
ActiveX Data Objects (ADO), versions 2.0, 2.1 SP2
SYMPTOMS
When the Close method of an ActiveX Data Objects (ADO) RecordSet object is
called, the WillChangeRecordset event does not fire. The documentation
states, in error, that this event fires when closing the RecordSet.
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article.
MORE INFORMATION
Steps to Reproduce Behavior
- Create a Standard EXE Project in Visual Basic.
- From Project menu, choose Components and then select "Microsoft
ActiveX Data Objects Library".
- Add a TextBox control and Command Button to the form.
- Add the following code to the General Declarations of the form:
Dim WithEvents rst As ADODB.Recordset
Dim cn As New ADODB.Connection
Private Sub Form_Load()
With cn
.CursorLocation = adUseClient
.Open "dsn=pubs;uid=sa;pwd=;"
End With
Set rst = cn.Execute("Select * from Authors", , adOpenStatic)
Set Text1.DataSource = rst
Text1.DataField = "au_lname"
End Sub
Private Sub rst_WillChangeRecordset(ByVal adReason As _
ADODB.EventReasonEnum, adStatus As ADODB.EventStatusEnum, _
ByVal pRecordset As ADODB.Recordset)
Debug.Print "ADO WillChangeRecordset"
End Sub
Private Sub Command1_Click()
Debug.Print "About to Close"
rst.Close
Debug.Print "Close complete"
Unload Me
End Sub
NOTE: The preceding code sample assumes that you have a DSN that points to
a valid SQL Server and the Pubs database.
- Press the F5 key to run the application and
then click the Command Button.
Notice that in the Debug Window the "ADO WillChangeRecordset" is not
printed after "About to Close" prints.
NOTE: It is printed when the RecordSet object is first created on the cn.Execute line.
REFERENCES
For additional information about ActiveX Data Objects (ADO) events, please
refer to the Data Access Software Development Kit (DASDK), Microsoft Data
Access Components (MDAC) or the Visual Studio 6.0 documentation.
For the latest ActiveX Data Objects (ADO) information and updates please
see the following URL:
http://www.microsoft.com/data/
Additional query words:
Keywords : kbADO200 kbADO210bug kbDatabase kbGrpVBDB kbGrpMDAC kbDSupport kbADO210sp2 kbMDAC210SP2
Version : WINDOWS:2.0,2.1 SP2
Platform : WINDOWS
Issue type : kbbug