PRB: Illegal to Use Find Methods w/ SQL PASSTHROUGH & ODBC DBLast reviewed: June 21, 1995Article ID: Q106111 |
The information in this article applies to:
- Professional Edition of Microsoft Visual Basic for Windows, version 3.0
SYMPTOMSWhen 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."
CAUSEFindFirst, 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.
RESOLUTIONThe 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 STATUSThis behavior is by design.
REFERENCEPages 58-60, Visual Basic Professional Edition, Version 3.0, "Professional Features Book 2."
MORE INFORMATION
Steps to Reproduce BehaviorThe 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
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |