PRB: ErrorNum 10034 When Calling SqlSetOpt%()

Last reviewed: April 28, 1997
Article ID: Q81396

The information in this article applies to:

  - Microsoft SQL Server Programmer's Toolkit, version 4.2

SYMPTOMS

The optparam$ parameter of the Visual Basic Library for SQL Server (VBSQL) function SqlSetOpt%() specifies the desired parameter of a particular option to be set. This parameter must always be passed to the function as a string enclosed in quotation marks, even in the case of numeric values. For example, the following line of code calls the SqlSetOpt%() function and sets the SQLBUFFER option to 100 rows:

   Results% = SqlSetOpt%(SqlConn%, SQLBUFFER, "100")

In addition, it is also possible to pass the parameter to the function as a string variable:

   Size$ = "100"
   Results% = SqlSetOpt%(SqlConn%, SQLBUFFER, Size$)

However, in Basic, it is common to convert numeric variables to strings with the STR$ function before passing them to other functions. This can lead to problems when calling SqlSetOpt%() because during the conversion process, the STR$ function automatically concatenates a space onto the left side of the resulting string. This additional space causes SqlSetOpt%() to fail with the following error:

   ErrorNum 10034
   Invalid or out of range dboption parameter

WORKAROUND

To work around this problem, you can use the LTRIM$ function to strip off any leading spaces prior to calling SqlSetOpt%(). The following example works properly:

   Size% = 100
   Results% = SqlSetOpt%(SqlConn%, SQLBUFFER, LTRIM$(STR$(Size%)))


Additional query words:
Keywords : kbinterop SSrvVisB
Version : 4.2
Platform : OS/2


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 28, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.