Used to set named parameters to be passed into SQL statements.

Note that must be defined in the same order as they appear in the SQL statement as native FoxPro parameters are injected as ? parameters, and ADO parameters are always treated sequentially.

For SQL Passthrough (wwSQL) this method has extra overhead - use FoxPro's native ? parameter syntax instead. For ADO, this method is more efficient. It works for mechanisms so if you want to create universally usable code use this method.

                     lcDirection, lnAdoType,

Return Value



The Value for the parameter

The name of the parameter


Optional - The ADO type when using wwAdoSql ignored in wwSql. If no type is specified wwAdoSql will take a best guess


Input parameters are automatically cleared the first time this method is called or after execution of a query. This ensures each query automatically starts with a clean parameter list and you don't have to explicitly keep clearing parameters. To override and keep parameters you can set lParameterReset = .F. before executing the first AddParameter() call on subsequent Execute commands.

wwAdoSql Specific Notes

The following notes do not apply to wwSql, only to wwAdoSql.

If wwAdoSql.nCodePage = 65001 (UTF-8) string parameters are passed and returned using Unicode. Otherwise string parameters are passed using plain VarChar or Text data.

By default all parameters are passed as VarChar(8000) when using Ansi text, and nVarChar(4000) when Unicode is used. If you specifically need to pass Text or nText explicitly you must override the type with 201 and 203 respectively.

Note, passing text/ntext output parameters is not working with ADO for reasons unknown. ADO will not pass the data to SQL Server but give an Unknown Error exception. Since it's not really possible to assign Text/nText data to a variable anyway, this point is kind of moot. However, the SQL Server docs do mention that it is supported. If you're returning Text/nText data that can't fit into VarChar/nVarChar you should return cursors rather than result values.


oSql.Addparameter(REPL("123 ",3000),"desc")

*** Use desc variable in the passthrough statement
? oSql.Executenonquery("update entries set description=?desc where id=8895")

See also:

Class wwsql

© West Wind Technologies, 2023 • Updated: 04/18/22
Comment or report problem with topic