BUG: ATL OLE DB provider returns incorrect length for variable-length string field (321909)
The information in this article applies to:
- Microsoft Visual Studio .NET (2002), Professional Edition
- Microsoft Visual Studio .NET (2002), Enterprise Architect Edition
- Microsoft Visual Studio .NET (2002), Enterprise Developer Edition
- Microsoft Visual Studio .NET (2002), Academic Edition
This article was previously published under Q321909 SYMPTOMS When you use an Active Template Library (ATL) provider
template to create an OLE DB provider that is linked to a server that is
running Microsoft SQL Server, the linked server returns garbage characters for
the variable-length field. CAUSE This problem occurs because of a bug in the TransferData method call code of the ATL OLE DB provider template.
RESOLUTION To work around this problem, change the following items in
the Atldb.h file:
- In TransferData method call, locate line 7329, which appears as follows:
if(pBindCur->dwPart & DBPART_LENGTH )
- Comment out the following two lines, which appear inside
this if condition:
if (!(pBindCur->dwPart & DBPART_VALUE))
cbDst = cbCol; // You do not have the data convert to correct this.
- Add the following code to line 7310:
cbDst=cbCol;
NOTE: Line 7310 appears after the end of the switch block and before
the following code:
// Handle cases in which you have provider-owned memory. NOTE: These should be
// with DBTYPE_BYREF (otherwise, this does not make sense).
if (pBindCur->dwPart & DBPART_VALUE)
{
if (pBindCur->dwMemOwner == DBMEMOWNER_PROVIDEROWNED && pBindCur->wType & DBTYPE_BYREF)
...... - Save your changes as a new file that is named Atldbnew.h,
and then use the Atldbnew.h file in your provider code.
This code change assigns the real string length to the obLength property of the binding structure for the provider-owned memory
scenario. STATUSMicrosoft has confirmed that this is a bug in the Microsoft
products that are listed at the beginning of this article.
Modification Type: | Minor | Last Reviewed: | 9/13/2005 |
---|
Keywords: | kbvs2002sp1sweep kbbug kbpending kbProvider KB321909 kbAudDeveloper |
---|
|