Microsoft KB Archive/198520

= BUG: You receive an "OLE DB Provider 'atlprov' reported an error" error message when you try to use an ATL wizard-generated OLE DB Provider in Visual C++ =

Article ID: 198520

Article Last Modified on 6/1/2005

-

APPLIES TO


 * Microsoft Visual C++ 6.0 Enterprise Edition
 * Microsoft SQL Server 7.0 Standard Edition
 * Microsoft SQL Server 2000 Standard Edition

-



This article was previously published under Q198520



SYMPTOMS
SQL Server 7.0 and SQL Server 2000 provide a mechanism for performing distributed queries against an OLE DB provider. You can use the new OpenQuery function or the 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, you receive a Server error message: 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
This behavior occurs because of the following problems in the Atldb.h header file:
 * The ATL IRowsetImpl::GetColumnInfo method fails to return information correctly.
 * The IRowsetImpl::GetData method does not handle provider-owned memory correctly.



RESOLUTION
The Atldbfix.h file, provided below, is a revised copy of the Atldb.h file that is included with Visual Studio Service Pack 5. Search the Atldbfix.h header file for "Fix:" to find where the changes have been made.

Instead of including the Atldb.h header file in your project, replace it with the Atldbfix.h file, after which you will encounter the following 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 that this is a problem in the Microsoft products that are listed in the "Applies to" section.



MORE INFORMATION
The following file is available for download from the Microsoft Download Center:

For Visual C++ 6.0, use the following file:

Atldbfix.exe

Release Date: Jan-07-2002

For more information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:

119591 How to obtain Microsoft support files from online services

Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help prevent any unauthorized changes to the file.

Steps to reproduce the 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 following command: Select * from OpenRowset('YourProviderName', '', 'c:\*.*')

