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++ (198520)



The information in this article applies to:

  • Microsoft Visual C++, 32-bit Enterprise Edition 6.0
  • Microsoft SQL Server 7.0
  • Microsoft SQL Server 2000 (all editions)

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: 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:\*.*')

REFERENCES

For more information and to download a Support WebCast, visit the following Microsoft Web site:

Creating, Using, and Debugging OLE DB Providers for SQL Server 7.0 Distributed Queries
http://support.microsoft.com/servicedesks/webcasts/wc102699/WC102699.asp


Modification Type:MajorLast Reviewed:6/1/2005
Keywords:kberrmsg kbtshoot kbdownload kbBug kbConsumer kbDatabase kbfile kbMDACNoSweep kbpatch kbpending kbSQLProg KB198520 kbAudDeveloper