Microsoft KB Archive/172239

= BUG: OpenResultset Doesn't Fire QueryComplete in Class Module =

Article ID: 172239

Article Last Modified on 11/7/2003

-

APPLIES TO


 * Microsoft Visual Basic 5.0 Enterprise Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition

-



This article was previously published under Q172239



SYMPTOMS
Program code in the QueryComplete event procedure of a rdoConnection object will not execute if you use the OpenResultset method to execute a query in a class module.



RESOLUTION
The resolution to this problem is to call DoEvents function after opening the resultset. For example: Set rs = cn.OpenResultset("select * from Authors", _      rdOpenKeyset, rdConcurValues) DoEvents If you use the OpenResultset method with the rdAsyncEnable option, you need to use the following code to workaround the problem: Set rs = cn.OpenResultset("select * from Authors", _      rdOpenKeyset, rdConcurValues, rdAsyncEnable) While rs.StillExecuting DoEvents Wend DoEvents



STATUS
Microsoft is researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.



Steps to Reproduce Behavior
 Start a new Standard EXE project in Visual Basic 5.0. Form1 is created by default. Add a new Class Module (Class1) to the project.  Insert the following code into the General Declarations section of Class1 and replace ServerName with appropriate SQL server name.

Note You must change UID = and PWD = to the correct values before you run this code. Make sure that UID has the appropriate permissions to perform this operation on the database. Private WithEvents cn As rdoConnection

Private Sub cn_QueryComplete(ByVal Query As RDO.rdoQuery, _                                 ByVal ErrorOccurred As Boolean) MsgBox "Query Done --> From QueryComplete Event." End Sub

Public Sub QueryCompleteTest Dim rs As rdoResultset Set cn = New rdoConnection With cn          .Connect = "UID= ;PWD= ;database=pubs;" _ & "Server=ServerName;" _ & "driver={SQL Server};DSN='';" .QueryTimeout = 5 .CursorDriver = rdUseClientBatch .EstablishConnection rdDriverNoPrompt End With Set rs = cn.OpenResultset( _          "select * from Authors", _           rdOpenKeyset, rdConcurValues) 'DoEvents End Sub  Add a CommandButton (Command1) to Form1.  Insert the following code into the Click event of Command1: Private Sub Command1_Click Dim ClsQuery As New Class1 ClsQuery.QueryCompleteTest End Sub  Select Project\References, and check Microsoft Remote Data Object 2.0.</li> Press the F5 key to run the program.</li> Click on Command1. Note that the QueryComplete event is not triggered and no message box appears on screen.</li></ol>

Additional query words: kbVBp500 kbVBp600 kbdse kbDSupport kbVBp kbVBp400 kbRDO

Keywords: kbbug KB172239

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.