The functions dbsetopt and dbclropt use the following constants, defined in Sqldb.h, for setting and clearing options. All options are off by default.
There are two ways to convert data with transfers to and from the server:
For Windows NT, use the SQL Server Network Utility automatic ANSI to OEM option. This modifies the Registry under the following subtree:
HKEY_LOCAL_MACHINE\
SOFTWARE\
Microsoft\
MSSQLServer\
Client\
DB-Lib
This also sets the AutoAnsiToOem entry to ON (AutoAnsiToOem:REG_SZ:ON). This is the default entry.
The AutoANSItoOEM entry controls the default conversion behavior when you connect to a server. If AutoANSItoOEM is set to ON, conversion is turned on in the following cases:
If AutoANSItoOEM is set to OFF, conversion is turned off for all connections.
You can override the default conversion by calling dbsetopt after calling dbopen.
Use the DBANSItoOEM option to enable conversion when connecting an ANSI client to an OEM server. Use the DBOEMtoANSI option to enable conversion when connecting an OEM client (Windows NT Console application) to an ISO server. You cannot set both options for the same DBPROCESS.
Row buffering keeps a specified number of SQL Server result rows in the program’s memory. Without row buffering, the result row generated by each new dbnextrow call overwrites the contents of the previous result row. So use row buffering for programs that need to look at result rows nonsequentially.
When turned on, DBBUFFER reduces memory and performance because each row in the buffer must be allocated and freed individually. Therefore, write the application to turn on the DBBUFFER option only if it calls dbgetrow. Note that row buffering, an independent issue, has nothing to do with network buffering. (For more information about row buffering, see dbgetrow, dbnextrow, and dbclrbuf.
This option can be enabled for a client running Windows by placing the line UseClientCursors=ON in the [SQLSERVER] section of Win.ini. This option can be enabled for a client running Windows NT by setting the value UseClientCursors to ON (UseClientCursors : REG_SZ : ON) in the following Windows NT Registry key:
HKEY_LOCAL_MACHINE\
SOFTWARE\
Microsoft\
MSSQLServer\
Client\
DB-Lib
Note The value param refers to parameters of stored procedures.
Calls to functions such as dbsetopt can specify these parameters in either uppercase or lowercase. For the internal types that correspond to the offsets, see dbgetoff. Offsets are returned only if the batch contains no syntax errors.
Note When you use DBQUOTEDIDENT, you must set param to NULL.
The following table lists the functions and the parameters that are affected when DBQUOTEDIDENT is enabled.
Function | Parameter(s) |
---|---|
bcp_init | tblname |
dbrpcinit | rpcname |
dbupdatetext | dest_object src_object |
dbuse | dbname |
dbwritetext | objname |
When you call dbrpcinit, you must explicitly place quotation marks around remote procedure names that require quotation marks in the rpcname parameter. This example demonstrates the use of quotation marks in rpcname.
"My server".."My RPC"
In the case of huge text values, it may take some time for the entire text value to be returned over the network. To keep SQL Server from sending this extra text, use the DBTEXTSIZE option instead of DBTEXTLIMIT.
Note that, in programs that allow ad hoc queries, the application user can override this option with the Transact-SQL SET TEXTSIZE command. To set a text limit that the user cannot override, use the DBTEXTLIMIT option instead.
DBBUFFER, DBNOAUTOFREE, and DBTEXTLIMIT are DB-Library options. That is, they affect DB-Library but are not sent to SQL Server. The others are SQL Server options (options that get sent to the SQL Server). You can set them with Transact-SQL.
As mentioned in the preceding descriptions, certain options take parameters. The following table lists these options and the possible values of their parameters.
Option | Possible parameter values |
---|---|
DBBUFFER | 0 to 32767 |
DBOFFSET | select, from, table, order, compute, statement, procedure, execute, or param |
DBROWCOUNT | 0 to 2,147,483,647 |
DBSTAT | io or time |
DBTEXTLIMIT | 0 to 65,534 for 16-bit DB-Library 0 to 2,147,483,647 for 32-bit DB-Library |
DBTEXTSIZE | 0 to 2,147,483,647 |
The function dbsetopt requires you to specify parameters when setting any of the options in the preceding table. On the other hand, the functions dbclropt and dbisopt require you to specify a parameter only for DBOFFSET and DBSTAT, because they can have simultaneous multiple settings, which require further definition before being cleared or checked.
Note that parameters specified in calls to dbsetopt, dbclropt, and dbisopt are always passed as character strings and enclosed in quotation marks, even if they are numeric values.