PRB: dbwritetext Returns SQL Server Message 156

Last reviewed: April 3, 1997
Article ID: Q105102

The information in this article applies to:

  - Microsoft SQL Server Programmer's Toolkit, version 4.2

SYMPTOMS

When attempting to call the dbwritetext function to update a text or image value, a DB-Library application can receive the following error message 156:

   Incorrect syntax near the keyword NULL.

CAUSE

This error is caused by passing a NULL text pointer value returned by dbtxptr, and a NULL text timestamp value returned by dbtxtimestamp, to the dbwritetext function.

The dbtxptr and dbtxtimestamp functions return pointers to values from the current DB-Library row, similar to dbdata. The dbtxptr and dbtxtimestamp functions can return NULL values for two reasons:

  1. The text or image value in the row and column returned by the SELECT statement is NULL.

  2. The dbtxptr and dbtxtimestamp functions are called when DB-Library has no current row. DB-Library has no current row when dbnextrow has returned NO_MORE_ROWS, or dbresults has returned NO_MORE_RESULTS.

WORKAROUND

Ensure that both the dbtxptr and dbtxtimestamp functions return valid, non-NULL values before passing them to dbwritetext. This can be achieved by ensuring that:

  1. The text or image value in the row and column returned by the SELECT statement is non-NULL.

  2. The dbtxptr and dbtxtimestamp functions are called when DB-Library has a valid current row. DB-Library has a current row when dbnextrow returns REG_ROW.

  3. The non-NULL values returned by dbtxptr and dbtxtimestamp are passed to dbwritetext while the same row is still current. In other words, do not call dbnextrow until these values are actually used.


Additional query words: 4.20 4.20.00 dblib
Keywords : kbprg SSrvDB_Lib SSrvProg
Version : 4.2
Platform : OS/2 Windows


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 3, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.