PRB: Illegal to Use Find Methods w/ SQL PASSTHROUGH & ODBC DB

Last reviewed: June 21, 1995
Article ID: Q106111
The information in this article applies to:

- Professional Edition of Microsoft Visual Basic for Windows, version 3.0

SYMPTOMS

When you create a Dynaset or Snapshot using the SQL PASSTHROUGH option with an ODBC database, the FindFirst, FindNext, FindLast, and FindPrevious methods give the error "Can't perform operation; it is illegal."

CAUSE

FindFirst, FindNext, FindLast, and FindPrevious work only on record sets opened by a query. Visual Basic version 3.0 doesn't use a query to open a record set when you use DB_SQLPASSTHROUGH, so these Find methods are not allowed, by design.

RESOLUTION

The SQL PASSTHROUGH option causes the query to be processed by an external database server, instead of by Visual Basic. Avoid using the SQL PASSTHROUGH option if you want to use the FindFirst, FindNext, FindLast, or FindPrevious methods with an ODBC database.

Also, you can avoid the problem by creating a copy of the dynaset or snapshot. This will allow the Microsoft Access Engine to perform the FindFirst rather than allowing the ODBC server to do it. However, the the dynaset copy must not use the SQL PASSTHROUGH option. Here is an example:

   Dim db as database
   Dim ds as dynaset
   Dim newds as dynaset

   Set db = OpenDatabase("", 0, 0, "ODBC;DSN=texas")
   Set ds = db.createdynaset("Select * from Authors", 64) ' SQL PASSTHROUGH
   Set newds = ds.createdynaset()  ' No SQL PASSTHROUGH
   newds.FindFirst ""  ' Now FindFirst works on newds

STATUS

This behavior is by design.

REFERENCE

Pages 58-60, Visual Basic Professional Edition, Version 3.0, "Professional Features Book 2."

MORE INFORMATION

Steps to Reproduce Behavior

The following code results in the "Can't perform operation; it is illegal" error:

   Dim db As database
   Set db = OpenDatabase("", 0, 0, "ODBC;DSN=texas")
   Dim ds As Dynaset   ' Creates a dynaset.
   ' The DB_SQLPASSTHROUGH option is 64:
   Set ds = db.CreateDynaset("select * from authors", 64)
   ds.FindFirst ""     ' FindFirst causes error message.


Additional reference words: 3.00
KBCategory: kbinterop 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: June 21, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.