Sets a Microsoft® SQL Server™ 2000 or DB-Library option.
RETCODE dbsetopt (
LPCSTR param );
Is the DBPROCESS structure that is the handle for a particular workstation or SQL Server 2000 process. It contains all the information that DB-Library uses to manage communications and data between the workstation and SQL Server. If dbproc is NULL, the option is set for all active DBPROCESS structures.
Is the option to be set. See DB-Library Options.
Is a parameter for an option. Certain options take parameters. For example, the DBOFFSET option takes as its parameter the construct for which offsets are to be returned:
dbsetopt(dbproc, DBOFFSET, "compute")
The DBBUFFER option takes as its parameter the number of rows to be buffered. A parameter with a negative value selects the default (currently 100 rows). A value of 1 is invalid.
dbsetopt(dbproc, DBBUFFER, "500")
Note The param variable must always be a character string enclosed in quotation marks, even in the case of a numeric value, as in the preceding DBBUFFER example.
If the option takes no parameters, param is ignored and may be NULL.
SUCCEED or FAIL.
This function fails if param is invalid for one of the DB-Library options. However, an invalid param for an SQL Server option does not cause dbsetopt to fail, because such a parameter does not get validated until the command buffer is sent to SQL Server.
Although SQL Server options can be set and cleared directly through Transact-SQL, the application should use dbsetopt and dbclropt to set and clear options. This provides a uniform interface for setting both SQL Server and DB-Library options. It also allows the application to use the dbisopt function to check the status of an option.
This function does not immediately set the options specified. They are not set until the command buffer is sent to SQL Server (by invoking the dbsqlexec function). An additional result for each option set is returned through the dbresults function.