BUG: ATL OLE DB Provider Fails When Called from SQL 7.0 Query

ID: Q198520


The information in this article applies to:
  • Microsoft Visual C++, 32-bit Enterprise Edition, version 6.0
  • Microsoft SQL Server version 7.0


SYMPTOMS

SQL Server version 7.0 provides a mechanism for performing distributed queries against an OLE DB provider. This can be done by using the new OpenQuery or OpenRowset function. For example, the following SQL statement performs a query against an OLE DB provider called MyProv by using the command "Select * from table1":


Select * from OpenRowset('MyProv', '', 'Select * from table1') 
If an ATL wizard-generated OLE DB Provider is queried by using the following command, an error occurs:

select * from openrowset ('MyProv.MyProv', '','c:\*.*') 
The error message is:
Server: Msg 7399, Level 16, State 1, Line 1 OLE DB Provider 'atlprov' reported an error. The provider ran out of memory


CAUSE

There are a couple of fixes that must be made to the Atldb.h header file. The fundamental problem exists in two areas:

  • The ATL IRowsetImpl::GetColumnInfo method fails to return information correctly.


  • The IRowsetImpl::GetData method doesn't handle provider-owned memory correctly.



RESOLUTION

Atldbfix.h, provided below, is a revised copy of the Atldb.h file. Search the new header file for "Fix:" to find where the changes have been made.

Instead of including the Atldb.h header file in your project, you can replace it with the Atldbfix.h file, which is provided below in this article. Once you do that, you will encounter the next error message:

Server: Msg 7347, Level 16, State 1, Line 1 OLE DB Provider 'Atlprov' returned an unexpected data length for the fixed-length column '[].FileName'. The expected data length is 260, while the returned data length is 12.
This error is caused by a bug in the ATL wizard-generated code, which returns a fixed-length string when it should be returning a variable length string of type DBTYPE_STR.

In the ATL wizard-generated sample provider, change the following two lines in the provider column map from the following

PROVIDER_COLUMN_ENTRY("FileName", 4, cFileName)
   PROVIDER_COLUMN_ENTRY("AltFileName", 5, cAlternateFileName) 
to the following:

PROVIDER_COLUMN_ENTRY_STR("FileName", 4, cFileName)
   PROVIDER_COLUMN_ENTRY_STR("AltFileName", 5, cAlternateFileName) 


STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article.


MORE INFORMATION

The following file is available for download from the Microsoft Download Center. Click the file name below to download the file:

For Visual C++ 6.0, use:

Atldbfix.exe
Release Date: Nov-19-1999

For more information about how to download files from the Microsoft Download Center, please visit the Download Center at the following Web address
http://www.microsoft.com/downloads/search.asp
and then click How to use the Microsoft Download Center.

Steps to Reproduce Behavior

  1. Create an ATL project using the ATL COM AppWizard.


  2. Create an ATL OLE DB Provider. On the Insert menu, click New ATL Object, and then select Data Access for the category and Provider for the object.


  3. Build the ATL OLE DB Provider.


  4. Register the provider on a machine with SQL Server 7.0 installed.


  5. Run a query against the provider by using the command:
    
    Select * from OpenRowset('YourProviderName', '', 'c:\*.*') 



REFERENCES

For additional information, see the Support WebCast at the following location:

http://support.microsoft.com/servicedesks/webcasts/wc102699/WC102699.asp

Additional query words:

Keywords : kbfile kbpatch kbDatabase kbOLEDB kbSQL kbVC600bug kbATL300bug kbConsumer kbDSupport kbGrpOLEDB
Version : WINDOWS:6.0; winnt:7.0
Platform : WINDOWS winnt
Issue type : kbbug


Last Reviewed: January 28, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.