Requery Method Not Available on PassThrough Queries

Last reviewed: April 5, 1996
Article ID: Q129925
The information in this article applies to:
  • Professional and Enterprise Editions of Microsoft Visual Basic, 16-bit and 32-bit, for Windows, version 4.0

SUMMARY

Visual Basic version 4.0 adds the Requery method for the RecordSet object. This method updates the data in a Recordset object by re-executing the query on which the object is based. When you use Requery, all changes made to the data in the underlying table by other users are displayed in the Recordset, and the first record in the Recordset becomes the current record. This method is not available for RecordSets created using the OpenRecordset method with the dbSQLPassthrough option.

CAUSE

The Requery method requires that column IDs are maintained and that column datatypes and names are the same. For passthrough queries Visual Basic passes the query through to the ODBC database without parsing it and has no way of knowing that these values will be maintained, so it disallows requery. The same is true for Crosstab queries without fixed column lists.

STATUS

This behavior is by design.

MORE INFORMATION

You can test whether or not your RecordSet can be Requeried by checking the Restartable property of your RecordSet. The Restartable property returns a value that indicates whether a Recordset object supports the Requery method.

Steps to Reproduce Behavior in Visual Basic Version 4.0

You will need an ODBC datasource to query against. This example assumes a DSN called "Pubs" exists with table named "Authors".

  1. Start a new project in Visual Basic. Form1 is created by default.

  2. Add the following code to the Form1_Click procedure.

       Sub Form_Click()
          Dim MyDB As Database, MyData As Recordset
          Set MyDB = DBEngine.Workspaces(0).OpenDatabase("", False, False, _
             "ODBC;DSN=pubs;uid=sa;pwd=")
          Set MyData = MyDB.OpenRecordset("Select * From authors",_
             dbOpenDynaset, dbSQLPassThrough)
          'other code here
          If MyData.Restartable = True Then '<== This will always be false.
             MsgBox "This RecordSet will be Requeried."
             MyData.Requery
          Else
             MsgBox "This RecordSet will not be Requeried."
             MyData.Close
          End If
          MyDB.Close
       End Sub
    
    

  3. Start the program by choosing Run Start (or press the F5 key).

The MyData.Restartable property will always be False, since the sample uses ExecuteSQL.


Additional reference words: 4.00 vb4win vb4all
KBCategory: kbprg kbprb
KBSubcategory: APrgDataODBC


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 5, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.