Problem with IDL for COM server returning ADO disconnected Recordset 
Author Message
 Problem with IDL for COM server returning ADO disconnected Recordset

I am using the following (snippets!) of idl for my component:

1. My component .idl file contains:

import "import_ado.idl";
...
interface IExecute : IDispatch
{
  [id(1), helpstring("method ExecuteCommand")] HRESULT ExecuteCommand([in]
_Command *cmd, [out, retval] _Recordset **ppRS);

Quote:
}

...
library XYZ
{
...
 coclass XYZStuff
 {
  [default] interface IAdmDatabaseConn;
  interface IExecute;
  interface IDatabaseSetup;
 };

Quote:
};

2. import_ado.idl contains

import "msado15.idl";
(I read somewhere that I could not directly import the msado15.idl into my
own IDL)

My component builds and works fine.

However, when I look at the VB Object Browser to see what interfaces my
component is exposing, I see that it exposes *all* of the ADO interfaces.
Obviously I do not want to do this :-) - i just want my own interfaces
exposed.

Any ideas what I am doing wrong?

Gary.



Tue, 09 Sep 2003 00:52:25 GMT  
 Problem with IDL for COM server returning ADO disconnected Recordset
Use importlib() to reference the ADO type library in your
library block. This is mandatory! BTW, what problems do you
encounter if you import ADO directly in your IDL? There
shouldn't be any problems...

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD

MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================


Quote:
> I am using the following (snippets!) of idl for my component:

> 1. My component .idl file contains:

> import "import_ado.idl";
> ...
> interface IExecute : IDispatch
> {
>   [id(1), helpstring("method ExecuteCommand")] HRESULT ExecuteCommand([in]
> _Command *cmd, [out, retval] _Recordset **ppRS);
> }
> ...
> library XYZ
> {
> ...
>  coclass XYZStuff
>  {
>   [default] interface IAdmDatabaseConn;
>   interface IExecute;
>   interface IDatabaseSetup;
>  };
> };

> 2. import_ado.idl contains

> import "msado15.idl";
> (I read somewhere that I could not directly import the msado15.idl into my
> own IDL)

> My component builds and works fine.

> However, when I look at the VB Object Browser to see what interfaces my
> component is exposing, I see that it exposes *all* of the ADO interfaces.
> Obviously I do not want to do this :-) - i just want my own interfaces
> exposed.

> Any ideas what I am doing wrong?

> Gary.



Tue, 09 Sep 2003 08:31:53 GMT  
 Problem with IDL for COM server returning ADO disconnected Recordset
The reference to the 'problem' with importing the IDL is from MSDN:
SAMPLE: ATL2ADO.exe Returns Disconnected ADO Recordset
As this is what I am also trying to achieve, I just started from this and
worked on.
So I took the position that I would benefit from someone else who had "been
there, done that" and just copied what had been provided.

Ok, I have followed your advice, so thanks for that (although I thought I
had tried this before, but as it's working now, I obviously did not).

Previously I had my 'interfaces' defined outside of the library block, so
needed to import the ado idl so that recordset & command were defined.
Using importlib within a library block will also define these, but now my
interfaces also need to be defined within the library block (else recordset
is not found).
But I guess (and I am guessing - another trip to MSDN is called for I think)
this is not a big deal.

So now I have

library XYZ
{
 importlib("stdole32.tlb");
 importlib("stdole2.tlb");

 importlib("msado25.tlb");

 [
 ]
 interface IExecute : IDispatch
 {
  [id(1), helpstring("method ExecuteCommand")] HRESULT ExecuteCommand([in]
_Command *cmd, [out, retval] _Recordset **ppRS);
 };
...

Quote:
};

and it is all fine.

Thanks again.


Quote:
> Use importlib() to reference the ADO type library in your
> library block. This is mandatory! BTW, what problems do you
> encounter if you import ADO directly in your IDL? There
> shouldn't be any problems...

> > 1. My component .idl file contains:

> > import "import_ado.idl";
> > ...
> > interface IExecute : IDispatch
> > {
> >   [id(1), helpstring("method ExecuteCommand")] HRESULT
ExecuteCommand([in]
> > _Command *cmd, [out, retval] _Recordset **ppRS);
> > }
> > ...
> > library XYZ
> > {
> > ...
> >  coclass XYZStuff
> >  {
> >   [default] interface IAdmDatabaseConn;
> >   interface IExecute;
> >   interface IDatabaseSetup;
> >  };
> > };

> > 2. import_ado.idl contains

> > import "msado15.idl";
> > (I read somewhere that I could not directly import the msado15.idl into
my
> > own IDL)



Tue, 09 Sep 2003 17:17:48 GMT  
 Problem with IDL for COM server returning ADO disconnected Recordset
No, it's not a big deal, because you use dual interfaces.

BTW, if you for some reason prefer the interfaces to be outside of
the library block (and I myself do prefer them that way!), you can
put them there, alright. Just remember that importlib is not a
substitute for import and vice versa. If you do both import and
importlib, you get the best of both worlds (IDL and ODL). That's
what I usually recommend.

BTW, MSDN articles like any other material may be wrong...
I know of at least one MSDN article that presented code which
actually outright crashed! It caused a lot of confusion about
how to raise events from worker threads... I believe it has
been revised now.

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD

MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================


Quote:
> The reference to the 'problem' with importing the IDL is from MSDN:
> SAMPLE: ATL2ADO.exe Returns Disconnected ADO Recordset
> As this is what I am also trying to achieve, I just started from this and
> worked on.
> So I took the position that I would benefit from someone else who had
"been
> there, done that" and just copied what had been provided.

> Ok, I have followed your advice, so thanks for that (although I thought I
> had tried this before, but as it's working now, I obviously did not).

> Previously I had my 'interfaces' defined outside of the library block, so
> needed to import the ado idl so that recordset & command were defined.
> Using importlib within a library block will also define these, but now my
> interfaces also need to be defined within the library block (else
recordset
> is not found).
> But I guess (and I am guessing - another trip to MSDN is called for I
think)
> this is not a big deal.

> So now I have

> library XYZ
> {
>  importlib("stdole32.tlb");
>  importlib("stdole2.tlb");

>  importlib("msado25.tlb");

>  [
>  ]
>  interface IExecute : IDispatch
>  {
>   [id(1), helpstring("method ExecuteCommand")] HRESULT ExecuteCommand([in]
> _Command *cmd, [out, retval] _Recordset **ppRS);
>  };
> ...
> };

> and it is all fine.

> Thanks again.



> > Use importlib() to reference the ADO type library in your
> > library block. This is mandatory! BTW, what problems do you
> > encounter if you import ADO directly in your IDL? There
> > shouldn't be any problems...

> > > 1. My component .idl file contains:

> > > import "import_ado.idl";
> > > ...
> > > interface IExecute : IDispatch
> > > {
> > >   [id(1), helpstring("method ExecuteCommand")] HRESULT
> ExecuteCommand([in]
> > > _Command *cmd, [out, retval] _Recordset **ppRS);
> > > }
> > > ...
> > > library XYZ
> > > {
> > > ...
> > >  coclass XYZStuff
> > >  {
> > >   [default] interface IAdmDatabaseConn;
> > >   interface IExecute;
> > >   interface IDatabaseSetup;
> > >  };
> > > };

> > > 2. import_ado.idl contains

> > > import "msado15.idl";
> > > (I read somewhere that I could not directly import the msado15.idl
into
> my
> > > own IDL)



Wed, 10 Sep 2003 04:38:39 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. problems passing ADO Recordset from VB-COM client to VC-COM-Server dll

2. Receiving an ADO disconnected recordset by a Com/DCOM object

3. Disconnected ADO Recordset

4. Disconnected ADO recordset

5. ADO Field Append and creating a disconnected recordset

6. Disconnected ADO Recordset in C++?

7. Multiple recordset with Disconnected ADO

8. Returning ADO Recordset Problem

9. Problem with ADO recordsets of recordsets under MTS

10. ADO Command problem in EXE Com server

11. error after returning ADO recordset

12. ATL COM return types in IDL

 

 
Powered by phpBB® Forum Software