Microsoft KB Archive/172239

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 12:30, 21 July 2020 by X010 (talk | contribs) (Text replacement - "&" to "&")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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.

MORE INFORMATION

Steps to Reproduce Behavior

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

    Note You must change UID =<username> 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=<username>;PWD=<strong password>;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
                            
  4. Add a CommandButton (Command1) to Form1.
  5. Insert the following code into the Click event of Command1:

          Private Sub Command1_Click()
            Dim ClsQuery As New Class1
            ClsQuery.QueryCompleteTest
          End Sub
                            
  6. Select Project\References, and check Microsoft Remote Data Object 2.0.
  7. Press the F5 key to run the program.
  8. Click on Command1. Note that the QueryComplete event is not triggered and no message box appears on screen.



Additional query words: kbVBp500 kbVBp600 kbdse kbDSupport kbVBp kbVBp400 kbRDO

Keywords: kbbug KB172239