Microsoft KB Archive/314972

= FIX: IColumnsInfo::GetColumnInfo Returns S_OK with ICommandPrepare::Prepare on Nonexistent Tables =

Article ID: 314972

Article Last Modified on 9/26/2005

-

APPLIES TO


 * Microsoft OLE DB Provider for Jet 4.0

-



This article was previously published under Q314972



SYMPTOMS
If your SELECT statement refers to a table name that does not exist or is not valid, OLE DB Provider for Jet 4.0 returns S_OK for the ICommandPrepare::Prepare method and the IColumnsInfo::GetColumnInfo method.

Although the Microsoft Jet engine returns an error message to the provider, the provider does not propagate the error message to the consumer.



RESOLUTION
The provider has been fixed so that IColumnsInfo::GetColumnInfo returns E_FAIL on nonexistent tables. To resolve this problem, install the latest Microsoft Jet service pack. For additional information about the latest Jet service pack, click the following article number to view the article in the Microsoft Knowledge Base:

239114 ACC2000: Updated Version of Microsoft Jet 4.0 Available in Download Center



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. For additional information about the latest Jet service pack, click the following article number to view the article in the Microsoft Knowledge Base:

239114 ACC2000: Updated Version of Microsoft Jet 4.0 Available in Download Center



MORE INFORMATION
Use the following code to reproduce this problem:

Note You must change the code to point to your existing .mdb file.
 * 1) include 
 * 2) include 

void main { HRESULT hr = CoInitialize( NULL ); assert( SUCCEEDED(hr) );

CDataSource ds;

//Jet 4.0 hr = ds.OpenFromInitializationString( OLESTR(&quot;Provider=Microsoft.Jet.OLEDB.4.0;&quot;) //You must change the following path to point to your database. OLESTR(&quot;Data Source=C:\\CPR\\CASES\\4323\\db1.mdb&quot;) );

assert( SUCCEEDED(hr) );

CSession sess; hr = sess.Open( ds ); assert( SUCCEEDED(hr) );

CCommand cmd; hr = cmd.Create( sess, _T(&quot;SELECT * FROM nosuchtable&quot;) ); assert( SUCCEEDED(hr) ); hr = cmd.Prepare; //This returns S_OK

CComPtr spColumnsInfo; hr = cmd.m_spCommand->QueryInterface( &spColumnsInfo ); assert( SUCCEEDED(hr) ); ULONG cColumns; DBCOLUMNINFO * rgInfo; OLECHAR * pStringsBuffer; //This returns S_OK even though cColumns is 0. hr = spColumnsInfo->GetColumnInfo( &cColumns, &rgInfo, &pStringsBuffer ); if (hr != E_FAIL) printf(&quot;\nReturned Success but should return E_FAIL\n&quot;); else printf(&quot;\nReturned E_FAIL. This is the correct behavior\n&quot;); } This code returns &quot;Returned Success but should return E_FAIL&quot; when you run the code. After you apply the latest Jet 4.0 service pack, this code returns &quot;Returned E_FAIL. This is the correct behavior&quot;.

Additional query words: non-existent non-existing invalid incorrect

Keywords: kbbug kbfix kbqfe kbhotfixserver KB314972

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.