I'm having a problem understanding the ICommandText::Execute method. I
have read MS OLE DB Programmer's Reference and I think I am doing what
it says to do. I am trying to execute some MDX against MS Analysis
Services and get back an IMDDataSet* from the ICommandText::Execute
method.
However, the ICommandText::Execute method returns a "No Such Interface
supported" error to me.
The MS Prog Ref states in "Controlling the Creation of Instances of a
Rowset or a Dataset" that one must set the DBPROP_IRowset property of
DBPROPSET_ROWSET to VARIANT_FALSE by using
ICommandProperties::SetProperties. I have done this, but the same "No
Such Interface supported" error is still returned.
Curiously, I have found further MS documentation (in the Prog Ref)
stating that the DBPROP_IRowset is read-only and cannot be changed.
This seems to be a contradiction.
Can anyone point out my error?
Here's a snippet of my code.
//==== Set the command properties
DBPROPSET cmdPropset[1];
DBPROP cmdProps[1];
cmdPropset[0].rgProperties = cmdProps;
cmdPropset[0].cProperties = 1;
cmdPropset[0].guidPropertySet = DBPROPSET_ROWSET;
cmdProps[0].dwPropertyID = DBPROP_IRowset;
cmdProps[0].dwOptions = DBPROPOPTIONS_REQUIRED;
cmdProps[0].colid = DB_NULLID;
cmdProps[0].vValue.vt = VT_BOOL;
cmdProps[0].vValue.boolVal = VARIANT_FALSE;
CATCH_COM_ERROR( pUnkCommand->QueryInterface( IID_ICommandProperties,
( void** ) &pICommandProperties ) );
CATCH_COM_ERROR( pICommandProperties->AddRef() );
CATCH_COM_ERROR( pICommandProperties->SetProperties( 1, cmdPropset )
);
//====
----> No COM errors. Everything seems to be Ok.
//==== Set and execute MDX
CATCH_COM_ERROR( pUnkCommand->QueryInterface( IID_ICommandText, (
void** ) &pICommandText ) );
CATCH_COM_ERROR( pICommandText->AddRef() );
CATCH_COM_ERROR( pICommandText->SetCommandText( MDGUID_MDX, MDX ) );
CATCH_COM_ERROR( pICommandText->Execute( NULL,
IID_IMDDataset,
NULL,
NULL,
( IUnknown** )&pIMDDataset ) );
//====
--->The Execute call throws the error stated above.
Also, if I change the requested IID to IID_IRowset (and supply the
corresponding pointer as the last parameter), no error is thrown.
I should point out that I am completely new to OLE DB programming.
Thanks in advance for your help.
I suspect there is a bug in the OLE DB for OLAP provider in handling command properties,
but I haven't had any need to take it up with MS. One of Microsoft's developers told me in
another newsgroup that asynchronous Execute()s were allowed, but when I set the command
properties accordingly I also get an E_NOINTERFACE error, and I haven't heard more from
them.
HTH
Gavin Berry wrote:
--
George Spofford
Microsoft MVP
Chief Architect / OLAP Solution Provider
DSS Lab
http://www.dsslab.com
geo...@dsslab.com
ISVs & IT organizations: Find out how DSS Lab can speed your development!
Thanks a lot for your comment. I changed my code so that it left all
properties untouched, but I'm afraid the same error presented itself.
Can I ask if your code requests an IID_IMDDataset or an IID_IRowset? I
can only get this working if I request an IID_IRowset from the Execute
method.
Gavin.
George Spofford <geo...@dsslab.com> wrote in message news:<3E25B4C8...@dsslab.com>...
Have you looked at the C++ sample code in the Samples subdirectory of your AS2K installation?
That will give you an example of working code. I don't know what else you have in your code that
may provoke the error. For example, connecting to the SQL provider instead of the OLAP provider
would certainly give you this error.
HTH
Gavin Berry wrote:
--
Thanks again. This will sound daft, but I never knew about those
samples ... and yes, I have now found the C++ OLE DB for OLAP sample
and it is of great help to me.
I had been solely working from the MS Data Access SDK.
Thanks a lot.
George Spofford <geo...@dsslab.com> wrote in message news:<3E2811EF...@dsslab.com>...