Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 314972 - Last Review: September 26, 2005 - Revision: 2.1
FIX: IColumnsInfo::GetColumnInfo() Returns S_OK with ICommandPrepare::Prepare on Nonexistent Tables
This article was previously published under Q314972
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.
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Â
(http://kbalertz.com/Feedback.aspx?kbNumber=239114/
)
ACC2000: Updated Version of Microsoft Jet 4.0 Available in Download Center
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Â
(http://kbalertz.com/Feedback.aspx?kbNumber=239114/
)
ACC2000: Updated Version of Microsoft Jet 4.0 Available in Download Center
Use the following code to reproduce this problem:
Note You must change the code to point to your existing .mdb file.
#include <atldbcli.h>
#include <assert.h>
void
main()
{
HRESULT hr = CoInitialize( NULL );
assert( SUCCEEDED(hr) );
CDataSource ds;
//Jet 4.0
hr = ds.OpenFromInitializationString(
OLESTR("Provider=Microsoft.Jet.OLEDB.4.0;")
//You must change the following path to point to your database.
OLESTR("Data Source=C:\\CPR\\CASES\\4323\\db1.mdb")
);
assert( SUCCEEDED(hr) );
CSession sess;
hr = sess.Open( ds );
assert( SUCCEEDED(hr) );
CCommand<CDynamicAccessor> cmd;
hr = cmd.Create( sess, _T("SELECT * FROM nosuchtable") );
assert( SUCCEEDED(hr) );
hr = cmd.Prepare(); //This returns S_OK
CComPtr<IColumnsInfo> 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("\nReturned Success but should return E_FAIL\n");
else
printf("\nReturned E_FAIL. This is the correct behavior\n");
}
This code returns "Returned Success but should return E_FAIL" when you run the code. After you apply the latest Jet 4.0 service pack, this code returns "Returned E_FAIL. This is the correct behavior".
APPLIES TO
- Microsoft OLE DB Provider for Jet 4.0
| kbhotfixserver kbqfe kbbug kbfix KB314972 |
Retired KB Content DisclaimerThis article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate