The information in this article applies to:
SYMPTOMSWhen using MFC ODBC to call a Microsoft SQL Server stored procedure that returns a CHAR or VARCHAR output parameter, the buffer intended to hold the data returned will be Null and ODBC will return the error:
CAUSEThis problem is caused by the way that parameters are bound in the RFX_Text function. The call to SQLBindParameter appears as follows:
The problem is the next to the last parameter, the cbValueMax argument,
which is hard coded to 0 (zero). The cbValueMax argument specifies the
length of the buffer; it applies only to character data, not to numerics.
If the number of bytes available to return is greater than or equal to this
number, then the driver truncates it to cbValueMax-1 and null terminates it
(and throws the error above). Because the parameter is hard coded to 0, the
error will always be returned.
RESOLUTIONThe resolution is to copy the RFX_Text function from Dbrfx.cpp and paste it into your project. Give it a name, such as RFX_TextOut, and then locate the SQLBindParameter call in question (right below the first UNICODE section). Change the SQLBindParameter call to the following:
By using the nMaxLength input parameter, the new RFX_Text function allows
the driver to set up a buffer of the correct size for the text Output
parameter.
STATUSMicrosoft is researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available. Additional query words:
Keywords : kbDatabase kbMFC kbODBC kbVC |
Last Reviewed: July 28, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |