Microsoft KB Archive/105102
PRB: dbwritetext Returns SQL Server Message 156
The information in this article applies to:
- Microsoft SQL Server Programmer's Toolkit, version 4.2
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.
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:
- The text or image value in the row and column returned by the SELECT statement is NULL.
- 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.
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:
- The text or image value in the row and column returned by the SELECT statement is non-NULL.
- 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.
- 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