HOWTO: Call a Stored Procedure Using the Data ControlLast reviewed: July 15, 1997Article ID: Q154758 |
The information in this article applies to:
SUMMARYWhen writing prototype or demo applications, it may sometimes be necessary to call a stored procedure on a SQL Server database from the Data Control. Because the Data Control behaves similarly to a Recordset in DAO code, it is possible to achieve this behavior.
MORE INFORMATIONIn order to pass SQL Server syntax through the JET engine (the engine that allows Visual Basic to connect to an Access databases), the dbSQLPassThrough option must be used. This prevents the parser built into JET from attempting to parse the SQL string. This ability to pass through the JET engine allows the Visual Basic programmer to call stored procedures on the SQL Server database. When using the Data Control, you can set the SQLPassThrough option to use the Options property of the data control. The Options property Online Documentation describes dbSQLPassThrough as follows:
Constant Value Description dbSQLPassThrough 64 When using Data controls with an SQL statement in the RecordSource property, sends the SQL statement to an ODBC database, such as a SQL Server or Oracle database, for processing.The complete list of valid settings for the Options property is documented in the Online Help. Search there for Options Property.
Step-by-Step ExampleThe following sample uses the pubs database in SQL Server to demonstrate the pass-through behavior. This contains a stored procedure called "byroyalty" that takes an integer and returns all authors that match the percentage royalty:
REFERENCESIn Visual Basic Online Help, see Options property, OpenRecordset method. Keywords : APrgDataODBC VB4ALL VB4WIN vb5all VBKBDB VBKBODBC kbhowto Version : 4.0 5.0 Platform : WINDOWS |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |