Re: ATL OLE DB Consumer Code problem
- From: Tony Hoyle <tmh@xxxxxxxxxxxx>
- Date: Thu, 3 Jan 2008 11:32:21 -0800 (PST)
On Dec 12 2007, 1:24 pm, Olivier MATROT <olivier.mat...@xxxxxxxxxxxxx>
wrote:
I'm using ATL OLE DB Consumer code, specifically a CCommand<TAccessor,
TRowset,TMulitple> based class. The accessor is of type CAccessor, the rowset
is of type CRowset and there is a single rowset returned by the query. The
query used is either a simple SQL SELECT Statement or a stored procedure call.
The same behavior is observed with either SQL Server OLE DB Provider or SQL
Native Client provider.
Sometimes, after creating the command on the session and excuting it
(CCommand::Open(...)), the return value is E_FAIL and there is no error
associated.
After digging in the code, it appears that ICommand::Execute returns S_OK
but there is no rowset interface returned (GetInterface() == NULL). MSDN
documentation is not talking about this behavior. You could see the code in
the function CCommand<>::ExecuteAndBind(...) in atldbcli.h. Bind() is called
and returns E_FAIL.
Any help appreciated.
I'm seeing this issue also... spend the last couple of days on it.
The error seems to be that CMultipleResults is broken. At line 6796
of atldbcli.h you find within GetNextResult:
HRESULT hr = GetMultiplePtr()->GetResult(NULL, 0, GetIID(),
pulRowsAffected, (IUnknown**)GetInterfacePtr());
if (FAILED(hr))
return hr;
Which *should* initialise the result set pointer. This alas does not
work at all. pulRowsAffected is set to -1, hr returns S_OK, but the
interface pointer is not initialised. This causes later code within
oledb to assert.
The workaround seems to be to not use CMultipleResults (which is
virtually completely undocumented - a single page on MSDN giving a
short summary of what it's for that that's it, so I guess it's rarely
used).
Tony
.
- Follow-Ups:
- Re: ATL OLE DB Consumer Code problem
- From: Erland Sommarskog
- Re: ATL OLE DB Consumer Code problem
- Next by Date: Re: ATL OLE DB Consumer Code problem
- Next by thread: Re: ATL OLE DB Consumer Code problem
- Index(es):
Relevant Pages
|