Microsoft KB Archive/105102

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 15:03, 18 July 2020 by 3155ffGd (talk | contribs) (importing KB archive)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

PRB: dbwritetext Returns SQL Server Message 156

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.00 dblib

Keywords : kbprg SSrvDB_Lib SSrvProg
Version : 4.2
Platform : OS/2 WINDOWS
Issue type :


Last Reviewed: March 17, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.