The information in this article applies to:
SUMMARY
Microsoft Access does not directly support the use of pass-through SQL
(the ability to pass SQL commands directly to a server). However, you can
use Access Basic to perform dynamic data exchange (DDE) with the Q+E
application, which does support pass-through SQL. Using this method, you
can pass SQL commands to run stored procedures and other SQL commands. MORE INFORMATION
To use Q+E's pass-through SQL capabilities in Microsoft Access, create
the following function in a new or existing module.
The SQLPassThru() function initiates a DDE channel with Q+E. If Q+E is not available, the function attempts to start Q+E. If Q+E cannot be started, the function displays an error message and ends. If Q+E can be started, a DDE channel is initiated. The SQLPassThru() function then directs Q+E to display its Logon dialog box so you can log on to SQL Server. The SQL USE command is used to ensure that SQLPassThru() is in the database you specify, and SQLPassThru() runs the SQL command. After the command is run, SQLPassThru() exits the Q+E application and terminates the DDE channel that the function established. The following demonstrates a sample call to the SQLPassThru() function:
In the above example, the SQLPassThru() function will start Q+E and initiate a DDE channel, if possible. You will then be prompted to log on to a SQL Server. After you log on, the function will use the master database on the SQL Server and run the stored procedure sp_addlogin, which will add a login for a user named Ted with a password of "ted." After the command runs, the function will exit the Q+E application and terminate the DDE channel. NOTE: You must include quotation marks around both of the parameters to ensure that they are used properly. You may also have to include additional quotation marks in the SQL command you are sending to the SQL Server to ensure that the command is being processed correctly. For examples of the types of adjustments that you may need to make to the SQL command string, see the "Q+E for Microsoft Excel User's Guide." You can modify this function in many different ways, including:
REFERENCES
Microsoft Access "Language Reference," version 1.0, pages 115-126
Keywords : kbinterop QryPass |
Last Reviewed: March 11, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |