Variable Containing SQL String Can Be Used in DBExec()ID: Q108621 2.50 2.50a 2.50b 3.00 WINDOWS The information in this article applies to:
SUMMARYThe DBExec() command sends an SQL statement to the data source, where the statement is processed. When you are creating a user-defined query that is used to query a remote data source using DBExec(), the SQL statement can be stored in a variable and that variable can be substituted directly into the DBExec() command.
MORE INFORMATIONMost examples in the Connectivity Kit "User's Guide" show DBExec() being executed with the SQL statement directly in the DBExec() function. For example, page 39 of the Connectivity Kit "User's Guide" has the following in the example:
These kind of examples can be misleading; it seems as if the SQL statement
has to be specified directly in the DBExec.
However, DBExec() and any other function contained in the Connectivity Kit behave like other native functions do in FoxPro: a character string can be stored to a variable and then that variable can be substituted when the parameter is a character string (<expC2>). Page 38 of the Connectivity Kit "User's Guide" shows the syntax for DBExec() as follows:
Angle brackets (<>) surrounding text indicate information that the user
provides. This information can be a filename, an expression, a memory
variable name, and so on.
The following example shows that you can build an SQL statement from "x" and "y", store it in variable "z" and use "z" in the DBExec() command:
NOTE: If you are using Visual FoxPro for Windows, use SQLCONNECT(),
SQLEXEC(), and SQLDISCONNECT() instead of DBCONNECT(), DBEXEC(), and
DBDISCONNECT(). For more information about these functions, search for
"SQL" in the online Help.
Additional reference words: VFoxWin 3.00 FoxWin 2.50 2.50a 2.50b ODBC CK Relational Query By Example (RQBE) KBCategory: KBSubcategory: FxtoolCk
|
|
Last Reviewed: May 22, 1998 © 1999 Microsoft Corporation. All rights reserved. Terms of Use. |