Returning ADO Recordset Problem 
Author Message
 Returning ADO Recordset Problem

When I try to set the out/retval to an ADO Recordset the MIDL Compiler
returns the errors

error MIDL2025 : syntax error : expecting a type specification near
"_Recordset"

The IDL Code looks like:

HRESULT GetAddress([in] long lngAddrId, [out,retval] _Recordset
**rsAddress);

I am using importlib("msado15.dll") in the library section.

Any Ideas?



Sun, 05 Jan 2003 03:00:00 GMT  
 Returning ADO Recordset Problem

Greets,

    Providing one is using importlib() in the IDL file to resolve the ADO
references, one can then return the _Recordset* from the method.  Just make
sure that the interfaces are declared within the library block after the
importlib().  Also, at the top of the IDL file after the import statements,
add the following:

cpp_quote("#include <adoint.h>")

    This will add the necessary ADO defines to the MIDL generated header so
that _Recordset is declared correctly.

Regards,

Joe


Quote:
> When I try to set the out/retval to an ADO Recordset the MIDL Compiler
> returns the errors

> error MIDL2025 : syntax error : expecting a type specification near
> "_Recordset"

> The IDL Code looks like:

> HRESULT GetAddress([in] long lngAddrId, [out,retval] _Recordset
> **rsAddress);

> I am using importlib("msado15.dll") in the library section.

> Any Ideas?



Sun, 05 Jan 2003 03:00:00 GMT  
 Returning ADO Recordset Problem
Make the importlib() comes before the interface block that contains the
property/method returning the Recordset

e.g.

    importlib("c:\program files\common files\system\ado\msado15.dll");  //
need ADO

 [
  object,
  uuid(FBDCAE64-0B3F-4D7E-B53C-03C78E896CE1),
  dual,
  helpstring("IRecSet Interface"),
  pointer_default(unique)
 ]
 interface IRecSet : IDispatch
 {
  [propget, id(1), helpstring("property ActiveConnection")] HRESULT
ActiveConnection([out, retval] _Connection* *pVal);
  [propput, id(1), helpstring("property ActiveConnection")] HRESULT
ActiveConnection([in] _Connection* newVal);
 };
--
Marlon Reid
Professional Developer
Little Caesars Enterprise, Inc.



Sun, 05 Jan 2003 03:00:00 GMT  
 Returning ADO Recordset Problem
Moved the importlib() before the references to _Recordset in my IDL File,
and added the cpp_quote. Now MIDL returns:

error MIDL2009 : undefined symbol : _Recordset [ Parameter of Procedure
'GetAddress'  ]


Quote:
> Greets,

>     Providing one is using importlib() in the IDL file to resolve the ADO
> references, one can then return the _Recordset* from the method.  Just
make
> sure that the interfaces are declared within the library block after the
> importlib().  Also, at the top of the IDL file after the import
statements,
> add the following:

> cpp_quote("#include <adoint.h>")

>     This will add the necessary ADO defines to the MIDL generated header
so
> that _Recordset is declared correctly.

> Regards,

> Joe



> > When I try to set the out/retval to an ADO Recordset the MIDL Compiler
> > returns the errors

> > error MIDL2025 : syntax error : expecting a type specification near
> > "_Recordset"

> > The IDL Code looks like:

> > HRESULT GetAddress([in] long lngAddrId, [out,retval] _Recordset
> > **rsAddress);

> > I am using importlib("msado15.dll") in the library section.

> > Any Ideas?



Sun, 05 Jan 2003 03:00:00 GMT  
 Returning ADO Recordset Problem
Greets,

    Was the importlib() added *inside* the library block?  Here is what I
used:

cpp_quote("#include <adoint.h>")

[
    uuid(5846E4F9-8F2E-4203-83F8-D8B200415BC9),
    version(1.0),
    helpstring("ComTest 1.0 Type Library")
]
library COMTESTLib
{
    importlib("stdole32.tlb");
    importlib("stdole2.tlb");
    importlib("c:\winnt\system32\dllcache\msado21.tlb");

    [
        object,
        dual,
        uuid(7F594E14-82D4-48B8-9F63-553EF9FBDDEA),
        helpstring("IMyFirstInterface"),
        pointer_default(unique)
        ]
        interface IMyTest : IDispatch
        {
            [id(1), helpstring("method GetRecord")] HRESULT
GetRecord([out,retval] _Recordset* pRecordset);
        };

    [
        uuid(9B169538-6154-4BDA-AADE-86CF5669CE50),
        helpstring("MyRecord Class")
    ]
    coclass MyRecord
    {
        [default] interface IMyTest;
    };

Quote:
};

Regards,

Joe


Quote:
> Moved the importlib() before the references to _Recordset in my IDL File,
> and added the cpp_quote. Now MIDL returns:

> error MIDL2009 : undefined symbol : _Recordset [ Parameter of Procedure
> 'GetAddress'  ]



> > Greets,

> >     Providing one is using importlib() in the IDL file to resolve the
ADO
> > references, one can then return the _Recordset* from the method.  Just
> make
> > sure that the interfaces are declared within the library block after the
> > importlib().  Also, at the top of the IDL file after the import
> statements,
> > add the following:

> > cpp_quote("#include <adoint.h>")

> >     This will add the necessary ADO defines to the MIDL generated header
> so
> > that _Recordset is declared correctly.

> > Regards,

> > Joe



> > > When I try to set the out/retval to an ADO Recordset the MIDL Compiler
> > > returns the errors

> > > error MIDL2025 : syntax error : expecting a type specification near
> > > "_Recordset"

> > > The IDL Code looks like:

> > > HRESULT GetAddress([in] long lngAddrId, [out,retval] _Recordset
> > > **rsAddress);

> > > I am using importlib("msado15.dll") in the library section.

> > > Any Ideas?



Sun, 05 Jan 2003 03:00:00 GMT  
 Returning ADO Recordset Problem
Unfortunately this is not a valid solution if you are working on a 'large'
project with multiple idl files that contain interface definitions.  With a
large project you probably import these idl files into your 'main' idl file.
I use the following (notice the helper.idl):

[
...
 ]
 interface Ixxx : IDispatch
 {
  import "helper.idl";
  [id(1), helpstring("...")]
  HRESULT Method(
     [in]   long   nRecordId,
     [out, retval] _Recordset** ppRecordset);
 };

[
 uuid(),
 version(1.0),
 helpstring("...")
]
library xxxLib
{
 importlib("stdole32.tlb");
 importlib("stdole2.tlb");

 [
  uuid(...),
  helpstring("...")
 ]
 coclass xxx;

Quote:
};

helper.idl simply contains:

import "msado15.idl";

HTH, Piers


Quote:
> Greets,

>     Was the importlib() added *inside* the library block?  Here is what I
> used:

> cpp_quote("#include <adoint.h>")

> [
>     uuid(5846E4F9-8F2E-4203-83F8-D8B200415BC9),
>     version(1.0),
>     helpstring("ComTest 1.0 Type Library")
> ]
> library COMTESTLib
> {
>     importlib("stdole32.tlb");
>     importlib("stdole2.tlb");
>     importlib("c:\winnt\system32\dllcache\msado21.tlb");

>     [
>         object,
>         dual,
>         uuid(7F594E14-82D4-48B8-9F63-553EF9FBDDEA),
>         helpstring("IMyFirstInterface"),
>         pointer_default(unique)
>         ]
>         interface IMyTest : IDispatch
>         {
>             [id(1), helpstring("method GetRecord")] HRESULT
> GetRecord([out,retval] _Recordset* pRecordset);
>         };

>     [
>         uuid(9B169538-6154-4BDA-AADE-86CF5669CE50),
>         helpstring("MyRecord Class")
>     ]
>     coclass MyRecord
>     {
>         [default] interface IMyTest;
>     };
> };

> Regards,

> Joe



> > Moved the importlib() before the references to _Recordset in my IDL
File,
> > and added the cpp_quote. Now MIDL returns:

> > error MIDL2009 : undefined symbol : _Recordset [ Parameter of Procedure
> > 'GetAddress'  ]



> > > Greets,

> > >     Providing one is using importlib() in the IDL file to resolve the
> ADO
> > > references, one can then return the _Recordset* from the method.  Just
> > make
> > > sure that the interfaces are declared within the library block after
the
> > > importlib().  Also, at the top of the IDL file after the import
> > statements,
> > > add the following:

> > > cpp_quote("#include <adoint.h>")

> > >     This will add the necessary ADO defines to the MIDL generated
header
> > so
> > > that _Recordset is declared correctly.

> > > Regards,

> > > Joe



> > > > When I try to set the out/retval to an ADO Recordset the MIDL
Compiler
> > > > returns the errors

> > > > error MIDL2025 : syntax error : expecting a type specification near
> > > > "_Recordset"

> > > > The IDL Code looks like:

> > > > HRESULT GetAddress([in] long lngAddrId, [out,retval] _Recordset
> > > > **rsAddress);

> > > > I am using importlib("msado15.dll") in the library section.

> > > > Any Ideas?



Sun, 05 Jan 2003 03:00:00 GMT  
 Returning ADO Recordset Problem

Greets,

    An alternate solution is quite welcome, however please note that 'valid'
is a relative term unto the context in which it is presented.  I still
believe that my solution was correct, do you not agree?  :)

Regards,

Joe


Quote:
> Unfortunately this is not a valid solution if you are working on a 'large'
> project with multiple idl files that contain interface definitions.  With
a
> large project you probably import these idl files into your 'main' idl
file.
> I use the following (notice the helper.idl):

> [
> ...
>  ]
>  interface Ixxx : IDispatch
>  {
>   import "helper.idl";
>   [id(1), helpstring("...")]
>   HRESULT Method(
>      [in]   long   nRecordId,
>      [out, retval] _Recordset** ppRecordset);
>  };

> [
>  uuid(),
>  version(1.0),
>  helpstring("...")
> ]
> library xxxLib
> {
>  importlib("stdole32.tlb");
>  importlib("stdole2.tlb");

>  [
>   uuid(...),
>   helpstring("...")
>  ]
>  coclass xxx;
> };

> helper.idl simply contains:

> import "msado15.idl";

> HTH, Piers



> > Greets,

> >     Was the importlib() added *inside* the library block?  Here is what
I
> > used:

> > cpp_quote("#include <adoint.h>")

> > [
> >     uuid(5846E4F9-8F2E-4203-83F8-D8B200415BC9),
> >     version(1.0),
> >     helpstring("ComTest 1.0 Type Library")
> > ]
> > library COMTESTLib
> > {
> >     importlib("stdole32.tlb");
> >     importlib("stdole2.tlb");
> >     importlib("c:\winnt\system32\dllcache\msado21.tlb");

> >     [
> >         object,
> >         dual,
> >         uuid(7F594E14-82D4-48B8-9F63-553EF9FBDDEA),
> >         helpstring("IMyFirstInterface"),
> >         pointer_default(unique)
> >         ]
> >         interface IMyTest : IDispatch
> >         {
> >             [id(1), helpstring("method GetRecord")] HRESULT
> > GetRecord([out,retval] _Recordset* pRecordset);
> >         };

> >     [
> >         uuid(9B169538-6154-4BDA-AADE-86CF5669CE50),
> >         helpstring("MyRecord Class")
> >     ]
> >     coclass MyRecord
> >     {
> >         [default] interface IMyTest;
> >     };
> > };

> > Regards,

> > Joe



> > > Moved the importlib() before the references to _Recordset in my IDL
> File,
> > > and added the cpp_quote. Now MIDL returns:

> > > error MIDL2009 : undefined symbol : _Recordset [ Parameter of
Procedure
> > > 'GetAddress'  ]



> > > > Greets,

> > > >     Providing one is using importlib() in the IDL file to resolve
the
> > ADO
> > > > references, one can then return the _Recordset* from the method.
Just
> > > make
> > > > sure that the interfaces are declared within the library block after
> the
> > > > importlib().  Also, at the top of the IDL file after the import
> > > statements,
> > > > add the following:

> > > > cpp_quote("#include <adoint.h>")

> > > >     This will add the necessary ADO defines to the MIDL generated
> header
> > > so
> > > > that _Recordset is declared correctly.

> > > > Regards,

> > > > Joe



> > > > > When I try to set the out/retval to an ADO Recordset the MIDL
> Compiler
> > > > > returns the errors

> > > > > error MIDL2025 : syntax error : expecting a type specification
near
> > > > > "_Recordset"

> > > > > The IDL Code looks like:

> > > > > HRESULT GetAddress([in] long lngAddrId, [out,retval] _Recordset
> > > > > **rsAddress);

> > > > > I am using importlib("msado15.dll") in the library section.

> > > > > Any Ideas?



Mon, 06 Jan 2003 03:00:00 GMT  
 Returning ADO Recordset Problem
Actually neither solution seems to be working.

if I include the msado15.idl file MIDL compiles OK, but the compiler then
complains:

fatal error C1083: Cannot open include file: 'msado15.h'
in my components header file. The line that is automatically added is
#import "msado15.h"

if I do the importlib on the dll, tlb or otherwise (in the library section),
I still get the original error message about not being able to recognize
_Recordset.


Quote:
> Greets,

>     An alternate solution is quite welcome, however please note that
'valid'
> is a relative term unto the context in which it is presented.  I still
> believe that my solution was correct, do you not agree?  :)

> Regards,

> Joe



> > Unfortunately this is not a valid solution if you are working on a
'large'
> > project with multiple idl files that contain interface definitions.
With
> a
> > large project you probably import these idl files into your 'main' idl
> file.
> > I use the following (notice the helper.idl):

> > [
> > ...
> >  ]
> >  interface Ixxx : IDispatch
> >  {
> >   import "helper.idl";
> >   [id(1), helpstring("...")]
> >   HRESULT Method(
> >      [in]   long   nRecordId,
> >      [out, retval] _Recordset** ppRecordset);
> >  };

> > [
> >  uuid(),
> >  version(1.0),
> >  helpstring("...")
> > ]
> > library xxxLib
> > {
> >  importlib("stdole32.tlb");
> >  importlib("stdole2.tlb");

> >  [
> >   uuid(...),
> >   helpstring("...")
> >  ]
> >  coclass xxx;
> > };

> > helper.idl simply contains:

> > import "msado15.idl";

> > HTH, Piers



> > > Greets,

> > >     Was the importlib() added *inside* the library block?  Here is
what
> I
> > > used:

> > > cpp_quote("#include <adoint.h>")

> > > [
> > >     uuid(5846E4F9-8F2E-4203-83F8-D8B200415BC9),
> > >     version(1.0),
> > >     helpstring("ComTest 1.0 Type Library")
> > > ]
> > > library COMTESTLib
> > > {
> > >     importlib("stdole32.tlb");
> > >     importlib("stdole2.tlb");
> > >     importlib("c:\winnt\system32\dllcache\msado21.tlb");

> > >     [
> > >         object,
> > >         dual,
> > >         uuid(7F594E14-82D4-48B8-9F63-553EF9FBDDEA),
> > >         helpstring("IMyFirstInterface"),
> > >         pointer_default(unique)
> > >         ]
> > >         interface IMyTest : IDispatch
> > >         {
> > >             [id(1), helpstring("method GetRecord")] HRESULT
> > > GetRecord([out,retval] _Recordset* pRecordset);
> > >         };

> > >     [
> > >         uuid(9B169538-6154-4BDA-AADE-86CF5669CE50),
> > >         helpstring("MyRecord Class")
> > >     ]
> > >     coclass MyRecord
> > >     {
> > >         [default] interface IMyTest;
> > >     };
> > > };

> > > Regards,

> > > Joe



> > > > Moved the importlib() before the references to _Recordset in my IDL
> > File,
> > > > and added the cpp_quote. Now MIDL returns:

> > > > error MIDL2009 : undefined symbol : _Recordset [ Parameter of
> Procedure
> > > > 'GetAddress'  ]



> > > > > Greets,

> > > > >     Providing one is using importlib() in the IDL file to resolve
> the
> > > ADO
> > > > > references, one can then return the _Recordset* from the method.
> Just
> > > > make
> > > > > sure that the interfaces are declared within the library block
after
> > the
> > > > > importlib().  Also, at the top of the IDL file after the import
> > > > statements,
> > > > > add the following:

> > > > > cpp_quote("#include <adoint.h>")

> > > > >     This will add the necessary ADO defines to the MIDL generated
> > header
> > > > so
> > > > > that _Recordset is declared correctly.

> > > > > Regards,

> > > > > Joe



> > > > > > When I try to set the out/retval to an ADO Recordset the MIDL
> > Compiler
> > > > > > returns the errors

> > > > > > error MIDL2025 : syntax error : expecting a type specification
> near
> > > > > > "_Recordset"

> > > > > > The IDL Code looks like:

> > > > > > HRESULT GetAddress([in] long lngAddrId, [out,retval] _Recordset
> > > > > > **rsAddress);

> > > > > > I am using importlib("msado15.dll") in the library section.

> > > > > > Any Ideas?



Mon, 06 Jan 2003 03:00:00 GMT  
 Returning ADO Recordset Problem
Greets,

    It would seem that one does not quite have the header files that they
are using.  Note that in the IDL code that I had provided, I did not use
#import, yet instead used importlib() and added the cpp_quote() to provide
the #include <adoint.h> header in the MIDL generated code.  How did the
#import get in there from the code that I had provided?

Regards,

Joe


Quote:
> Actually neither solution seems to be working.

> if I include the msado15.idl file MIDL compiles OK, but the compiler then
> complains:

> fatal error C1083: Cannot open include file: 'msado15.h'
> in my components header file. The line that is automatically added is
> #import "msado15.h"

> if I do the importlib on the dll, tlb or otherwise (in the library
section),
> I still get the original error message about not being able to recognize
> _Recordset.



> > Greets,

> >     An alternate solution is quite welcome, however please note that
> 'valid'
> > is a relative term unto the context in which it is presented.  I still
> > believe that my solution was correct, do you not agree?  :)

> > Regards,

> > Joe



> > > Unfortunately this is not a valid solution if you are working on a
> 'large'
> > > project with multiple idl files that contain interface definitions.
> With
> > a
> > > large project you probably import these idl files into your 'main' idl
> > file.
> > > I use the following (notice the helper.idl):

> > > [
> > > ...
> > >  ]
> > >  interface Ixxx : IDispatch
> > >  {
> > >   import "helper.idl";
> > >   [id(1), helpstring("...")]
> > >   HRESULT Method(
> > >      [in]   long   nRecordId,
> > >      [out, retval] _Recordset** ppRecordset);
> > >  };

> > > [
> > >  uuid(),
> > >  version(1.0),
> > >  helpstring("...")
> > > ]
> > > library xxxLib
> > > {
> > >  importlib("stdole32.tlb");
> > >  importlib("stdole2.tlb");

> > >  [
> > >   uuid(...),
> > >   helpstring("...")
> > >  ]
> > >  coclass xxx;
> > > };

> > > helper.idl simply contains:

> > > import "msado15.idl";

> > > HTH, Piers



> > > > Greets,

> > > >     Was the importlib() added *inside* the library block?  Here is
> what
> > I
> > > > used:

> > > > cpp_quote("#include <adoint.h>")

> > > > [
> > > >     uuid(5846E4F9-8F2E-4203-83F8-D8B200415BC9),
> > > >     version(1.0),
> > > >     helpstring("ComTest 1.0 Type Library")
> > > > ]
> > > > library COMTESTLib
> > > > {
> > > >     importlib("stdole32.tlb");
> > > >     importlib("stdole2.tlb");
> > > >     importlib("c:\winnt\system32\dllcache\msado21.tlb");

> > > >     [
> > > >         object,
> > > >         dual,
> > > >         uuid(7F594E14-82D4-48B8-9F63-553EF9FBDDEA),
> > > >         helpstring("IMyFirstInterface"),
> > > >         pointer_default(unique)
> > > >         ]
> > > >         interface IMyTest : IDispatch
> > > >         {
> > > >             [id(1), helpstring("method GetRecord")] HRESULT
> > > > GetRecord([out,retval] _Recordset* pRecordset);
> > > >         };

> > > >     [
> > > >         uuid(9B169538-6154-4BDA-AADE-86CF5669CE50),
> > > >         helpstring("MyRecord Class")
> > > >     ]
> > > >     coclass MyRecord
> > > >     {
> > > >         [default] interface IMyTest;
> > > >     };
> > > > };

> > > > Regards,

> > > > Joe



> > > > > Moved the importlib() before the references to _Recordset in my
IDL
> > > File,
> > > > > and added the cpp_quote. Now MIDL returns:

> > > > > error MIDL2009 : undefined symbol : _Recordset [ Parameter of
> > Procedure
> > > > > 'GetAddress'  ]



> > > > > > Greets,

> > > > > >     Providing one is using importlib() in the IDL file to
resolve
> > the
> > > > ADO
> > > > > > references, one can then return the _Recordset* from the method.
> > Just
> > > > > make
> > > > > > sure that the interfaces are declared within the library block
> after
> > > the
> > > > > > importlib().  Also, at the top of the IDL file after the import
> > > > > statements,
> > > > > > add the following:

> > > > > > cpp_quote("#include <adoint.h>")

> > > > > >     This will add the necessary ADO defines to the MIDL
generated
> > > header
> > > > > so
> > > > > > that _Recordset is declared correctly.

> > > > > > Regards,

> > > > > > Joe



> > > > > > > When I try to set the out/retval to an ADO Recordset the MIDL
> > > Compiler
> > > > > > > returns the errors

> > > > > > > error MIDL2025 : syntax error : expecting a type specification
> > near
> > > > > > > "_Recordset"

> > > > > > > The IDL Code looks like:

> > > > > > > HRESULT GetAddress([in] long lngAddrId, [out,retval]
_Recordset
> > > > > > > **rsAddress);

> > > > > > > I am using importlib("msado15.dll") in the library section.

> > > > > > > Any Ideas?



Mon, 06 Jan 2003 03:00:00 GMT  
 Returning ADO Recordset Problem

Joe:

One approach that I use is to return the ADODB Recordset as an IDispatch
interface pointer.
In other words, my IDL method declaration looks like this:

[id(1), helpstring("method List")] HRESULT List([out, retval] LPDISPATCH
*ADODBRecordset);

In my StdAfx.h I've imported the ADO typelib as follows:
#import "D:\Program Files\Common Files\System\ado\msado15.dll" rename("EOF",
"ADOEOF") no_namespace

A sample implementation of the List method would be:

STDMETHODIMP CExperts::List(LPDISPATCH *ppADODBRecordset)
{
         HRESULT hr = S_OK;
         try
         {
              _ConnectionPtr p_ado_conn;
              _RecordsetPtr  p_ado_rs;
              _bstr_t sql_cmd = L"SELECT * FROM Experts";
              _bstr_t connection_string = L"FILEDSN=TRZ Contacts";
              variant_t rows_affected;

              // create connection instance
              p_ado_conn.CreateInstance(__uuidof(Connection));

              // connect to the db
              hr = p_ado_conn->Open(connection_string,(BSTR)NULL, (BSTR)
NULL,-1);

              if (SUCCEEDED(hr))
              {
                   // exec the SQL cmd
                   p_ado_rs =
p_ado_conn->Execute(sql_cmd,&rows_affected,adCmdText);

                   // return IDispatch interface ptr Note: QI does an AddRef
on the interface pointer
                   hr =
p_ado_rs->QueryInterface(IID_IDispatch,(void**)ppADODBRecordset);
              }
         }
         catch(_com_error& e)
         {
              hr = e.Error();
         }
         catch(...)
         {
              hr = E_UNEXPECTED;
         }
         if (m_spObjectContext)
         {
              if (SUCCEEDED(hr))
                   m_spObjectContext->SetComplete();
              else
                   m_spObjectContext->SetAbort();
         }
         return hr;

Quote:
}

I've adopted this approach suggested in Mary Kirtland's book "Designing
Component Based Applications", MS Press.

Marc


Quote:
> Greets,

>     It would seem that one does not quite have the header files that they
> are using.  Note that in the IDL code that I had provided, I did not use
> #import, yet instead used importlib() and added the cpp_quote() to provide
> the #include <adoint.h> header in the MIDL generated code.  How did the
> #import get in there from the code that I had provided?

> Regards,

> Joe



> > Actually neither solution seems to be working.

> > if I include the msado15.idl file MIDL compiles OK, but the compiler
then
> > complains:

> > fatal error C1083: Cannot open include file: 'msado15.h'
> > in my components header file. The line that is automatically added is
> > #import "msado15.h"

> > if I do the importlib on the dll, tlb or otherwise (in the library
> section),
> > I still get the original error message about not being able to recognize
> > _Recordset.



> > > Greets,

> > >     An alternate solution is quite welcome, however please note that
> > 'valid'
> > > is a relative term unto the context in which it is presented.  I still
> > > believe that my solution was correct, do you not agree?  :)

> > > Regards,

> > > Joe



> > > > Unfortunately this is not a valid solution if you are working on a
> > 'large'
> > > > project with multiple idl files that contain interface definitions.
> > With
> > > a
> > > > large project you probably import these idl files into your 'main'
idl
> > > file.
> > > > I use the following (notice the helper.idl):

> > > > [
> > > > ...
> > > >  ]
> > > >  interface Ixxx : IDispatch
> > > >  {
> > > >   import "helper.idl";
> > > >   [id(1), helpstring("...")]
> > > >   HRESULT Method(
> > > >      [in]   long   nRecordId,
> > > >      [out, retval] _Recordset** ppRecordset);
> > > >  };

> > > > [
> > > >  uuid(),
> > > >  version(1.0),
> > > >  helpstring("...")
> > > > ]
> > > > library xxxLib
> > > > {
> > > >  importlib("stdole32.tlb");
> > > >  importlib("stdole2.tlb");

> > > >  [
> > > >   uuid(...),
> > > >   helpstring("...")
> > > >  ]
> > > >  coclass xxx;
> > > > };

> > > > helper.idl simply contains:

> > > > import "msado15.idl";

> > > > HTH, Piers



> > > > > Greets,

> > > > >     Was the importlib() added *inside* the library block?  Here is
> > what
> > > I
> > > > > used:

> > > > > cpp_quote("#include <adoint.h>")

> > > > > [
> > > > >     uuid(5846E4F9-8F2E-4203-83F8-D8B200415BC9),
> > > > >     version(1.0),
> > > > >     helpstring("ComTest 1.0 Type Library")
> > > > > ]
> > > > > library COMTESTLib
> > > > > {
> > > > >     importlib("stdole32.tlb");
> > > > >     importlib("stdole2.tlb");
> > > > >     importlib("c:\winnt\system32\dllcache\msado21.tlb");

> > > > >     [
> > > > >         object,
> > > > >         dual,
> > > > >         uuid(7F594E14-82D4-48B8-9F63-553EF9FBDDEA),
> > > > >         helpstring("IMyFirstInterface"),
> > > > >         pointer_default(unique)
> > > > >         ]
> > > > >         interface IMyTest : IDispatch
> > > > >         {
> > > > >             [id(1), helpstring("method GetRecord")] HRESULT
> > > > > GetRecord([out,retval] _Recordset* pRecordset);
> > > > >         };

> > > > >     [
> > > > >         uuid(9B169538-6154-4BDA-AADE-86CF5669CE50),
> > > > >         helpstring("MyRecord Class")
> > > > >     ]
> > > > >     coclass MyRecord
> > > > >     {
> > > > >         [default] interface IMyTest;
> > > > >     };
> > > > > };

> > > > > Regards,

> > > > > Joe



> > > > > > Moved the importlib() before the references to _Recordset in my
> IDL
> > > > File,
> > > > > > and added the cpp_quote. Now MIDL returns:

> > > > > > error MIDL2009 : undefined symbol : _Recordset [ Parameter of
> > > Procedure
> > > > > > 'GetAddress'  ]



> > > > > > > Greets,

> > > > > > >     Providing one is using importlib() in the IDL file to
> resolve
> > > the
> > > > > ADO
> > > > > > > references, one can then return the _Recordset* from the
method.
> > > Just
> > > > > > make
> > > > > > > sure that the interfaces are declared within the library block
> > after
> > > > the
> > > > > > > importlib().  Also, at the top of the IDL file after the
import
> > > > > > statements,
> > > > > > > add the following:

> > > > > > > cpp_quote("#include <adoint.h>")

> > > > > > >     This will add the necessary ADO defines to the MIDL
> generated
> > > > header
> > > > > > so
> > > > > > > that _Recordset is declared correctly.

> > > > > > > Regards,

> > > > > > > Joe



> > > > > > > > When I try to set the out/retval to an ADO Recordset the
MIDL
> > > > Compiler
> > > > > > > > returns the errors

> > > > > > > > error MIDL2025 : syntax error : expecting a type
specification
> > > near
> > > > > > > > "_Recordset"

> > > > > > > > The IDL Code looks like:

> > > > > > > > HRESULT GetAddress([in] long lngAddrId, [out,retval]
> _Recordset
> > > > > > > > **rsAddress);

> > > > > > > > I am using importlib("msado15.dll") in the library section.

> > > > > > > > Any Ideas?



Mon, 06 Jan 2003 03:00:00 GMT  
 Returning ADO Recordset Problem
Greets,

    Ah yes, returning the dispatch interface for the ADO recordset is
another good way to do this.  It is probably even preferred if one will be
using their interface from a scripting environment.  Thank you for the
alternate suggestion.

Regards,

Joe


Quote:
> Joe:

> One approach that I use is to return the ADODB Recordset as an IDispatch
> interface pointer.
> In other words, my IDL method declaration looks like this:

> [id(1), helpstring("method List")] HRESULT List([out, retval] LPDISPATCH
> *ADODBRecordset);

> In my StdAfx.h I've imported the ADO typelib as follows:
> #import "D:\Program Files\Common Files\System\ado\msado15.dll"
rename("EOF",
> "ADOEOF") no_namespace

> A sample implementation of the List method would be:

> STDMETHODIMP CExperts::List(LPDISPATCH *ppADODBRecordset)
> {
>          HRESULT hr = S_OK;
>          try
>          {
>               _ConnectionPtr p_ado_conn;
>               _RecordsetPtr  p_ado_rs;
>               _bstr_t sql_cmd = L"SELECT * FROM Experts";
>               _bstr_t connection_string = L"FILEDSN=TRZ Contacts";
>               variant_t rows_affected;

>               // create connection instance
>               p_ado_conn.CreateInstance(__uuidof(Connection));

>               // connect to the db
>               hr = p_ado_conn->Open(connection_string,(BSTR)NULL, (BSTR)
> NULL,-1);

>               if (SUCCEEDED(hr))
>               {
>                    // exec the SQL cmd
>                    p_ado_rs =
> p_ado_conn->Execute(sql_cmd,&rows_affected,adCmdText);

>                    // return IDispatch interface ptr Note: QI does an
AddRef
> on the interface pointer
>                    hr =
> p_ado_rs->QueryInterface(IID_IDispatch,(void**)ppADODBRecordset);
>               }
>          }
>          catch(_com_error& e)
>          {
>               hr = e.Error();
>          }
>          catch(...)
>          {
>               hr = E_UNEXPECTED;
>          }
>          if (m_spObjectContext)
>          {
>               if (SUCCEEDED(hr))
>                    m_spObjectContext->SetComplete();
>               else
>                    m_spObjectContext->SetAbort();
>          }
>          return hr;
> }

> I've adopted this approach suggested in Mary Kirtland's book "Designing
> Component Based Applications", MS Press.

> Marc



> > Greets,

> >     It would seem that one does not quite have the header files that
they
> > are using.  Note that in the IDL code that I had provided, I did not use
> > #import, yet instead used importlib() and added the cpp_quote() to
provide
> > the #include <adoint.h> header in the MIDL generated code.  How did the
> > #import get in there from the code that I had provided?

> > Regards,

> > Joe



> > > Actually neither solution seems to be working.

> > > if I include the msado15.idl file MIDL compiles OK, but the compiler
> then
> > > complains:

> > > fatal error C1083: Cannot open include file: 'msado15.h'
> > > in my components header file. The line that is automatically added is
> > > #import "msado15.h"

> > > if I do the importlib on the dll, tlb or otherwise (in the library
> > section),
> > > I still get the original error message about not being able to
recognize
> > > _Recordset.



> > > > Greets,

> > > >     An alternate solution is quite welcome, however please note that
> > > 'valid'
> > > > is a relative term unto the context in which it is presented.  I
still
> > > > believe that my solution was correct, do you not agree?  :)

> > > > Regards,

> > > > Joe



> > > > > Unfortunately this is not a valid solution if you are working on a
> > > 'large'
> > > > > project with multiple idl files that contain interface
definitions.
> > > With
> > > > a
> > > > > large project you probably import these idl files into your 'main'
> idl
> > > > file.
> > > > > I use the following (notice the helper.idl):

> > > > > [
> > > > > ...
> > > > >  ]
> > > > >  interface Ixxx : IDispatch
> > > > >  {
> > > > >   import "helper.idl";
> > > > >   [id(1), helpstring("...")]
> > > > >   HRESULT Method(
> > > > >      [in]   long   nRecordId,
> > > > >      [out, retval] _Recordset** ppRecordset);
> > > > >  };

> > > > > [
> > > > >  uuid(),
> > > > >  version(1.0),
> > > > >  helpstring("...")
> > > > > ]
> > > > > library xxxLib
> > > > > {
> > > > >  importlib("stdole32.tlb");
> > > > >  importlib("stdole2.tlb");

> > > > >  [
> > > > >   uuid(...),
> > > > >   helpstring("...")
> > > > >  ]
> > > > >  coclass xxx;
> > > > > };

> > > > > helper.idl simply contains:

> > > > > import "msado15.idl";

> > > > > HTH, Piers



> > > > > > Greets,

> > > > > >     Was the importlib() added *inside* the library block?  Here
is
> > > what
> > > > I
> > > > > > used:

> > > > > > cpp_quote("#include <adoint.h>")

> > > > > > [
> > > > > >     uuid(5846E4F9-8F2E-4203-83F8-D8B200415BC9),
> > > > > >     version(1.0),
> > > > > >     helpstring("ComTest 1.0 Type Library")
> > > > > > ]
> > > > > > library COMTESTLib
> > > > > > {
> > > > > >     importlib("stdole32.tlb");
> > > > > >     importlib("stdole2.tlb");
> > > > > >     importlib("c:\winnt\system32\dllcache\msado21.tlb");

> > > > > >     [
> > > > > >         object,
> > > > > >         dual,
> > > > > >         uuid(7F594E14-82D4-48B8-9F63-553EF9FBDDEA),
> > > > > >         helpstring("IMyFirstInterface"),
> > > > > >         pointer_default(unique)
> > > > > >         ]
> > > > > >         interface IMyTest : IDispatch
> > > > > >         {
> > > > > >             [id(1), helpstring("method GetRecord")] HRESULT
> > > > > > GetRecord([out,retval] _Recordset* pRecordset);
> > > > > >         };

> > > > > >     [
> > > > > >         uuid(9B169538-6154-4BDA-AADE-86CF5669CE50),
> > > > > >         helpstring("MyRecord Class")
> > > > > >     ]
> > > > > >     coclass MyRecord
> > > > > >     {
> > > > > >         [default] interface IMyTest;
> > > > > >     };
> > > > > > };

> > > > > > Regards,

> > > > > > Joe



> > > > > > > Moved the importlib() before the references to _Recordset in
my
> > IDL
> > > > > File,
> > > > > > > and added the cpp_quote. Now MIDL returns:

> > > > > > > error MIDL2009 : undefined symbol : _Recordset [ Parameter of
> > > > Procedure
> > > > > > > 'GetAddress'  ]



> > > > > > > > Greets,

> > > > > > > >     Providing one is using importlib() in the IDL file to
> > resolve
> > > > the
> > > > > > ADO
> > > > > > > > references, one can then return the _Recordset* from the
> method.
> > > > Just
> > > > > > > make
> > > > > > > > sure that the interfaces are declared within the library
block
> > > after
> > > > > the
> > > > > > > > importlib().  Also, at the top of the IDL file after the
> import
> > > > > > > statements,
> > > > > > > > add the following:

> > > > > > > > cpp_quote("#include <adoint.h>")

> > > > > > > >     This will add the necessary ADO defines to the MIDL
> > generated
> > > > > header
> > > > > > > so
> > > > > > > > that _Recordset is declared correctly.

> > > > > > > > Regards,

> > > > > > > > Joe



> > > > > > > > > When I try to set the out/retval to an ADO Recordset the
> MIDL
> > > > > Compiler
> > > > > > > > > returns the errors

> > > > > > > > > error MIDL2025 : syntax error : expecting a type
> specification
> > > > near
> > > > > > > > > "_Recordset"

> > > > > > > > > The IDL Code looks like:

> > > > > > > > > HRESULT GetAddress([in] long lngAddrId, [out,retval]
> > _Recordset
> > > > > > > > > **rsAddress);

> > > > > > > > > I am using importlib("msado15.dll") in the library
section.

> > > > > > > > > Any Ideas?



Mon, 06 Jan 2003 03:00:00 GMT  
 Returning ADO Recordset Problem
Hi,

I've been following this thread and tried to get something working.
I had tried different ways to insert:
- cpp_quote("#include <adoint.h>")
- importlib("c:\program files\common files\system\ado\msado15.dll")
but I kept on getting errors from the compiler.

Where & how should I place these two lines?  I've run out of idea now.
Thanks,

Iwan
PS: my IDL structure is as follow:
--------------------------------------------------------------------------
   import "oaidl.idl";
   import "ocidl.idl";
   [
      object,
      uuid(E72E4B92-9E7F-4F30-8EA3-E43576A681C5),
      dual,
      helpstring("ICustomer Interface"),
      pointer_default(unique)
   ]
   interface ICustomer : IDispatch
   {
      [id(1), helpstring("method GetCustomer")] HRESULT GetCustomer([in]
signed int CustomerId, [out,retval] _Recordset **pRSCustomer);
   };
   [
      uuid(867D006E-58DB-414B-A916-88A1CB2BD640),
      version(1.0),
      helpstring("MOP Objects 1.0 Library")
   ]
   library MOPLib
   {
      importlib("stdole32.tlb");
      importlib("stdole2.tlb");
      [
         uuid(C6C08E5D-C646-4E83-AC07-9B7FB9C53BAE),
         helpstring("Customer Class")
      ]
      coclass Customer
      {
         [default] interface ICustomer;
      };
   };
----------------------------------------------------------------------------
---


Quote:
> Greets,

>     It would seem that one does not quite have the header files that they
> are using.  Note that in the IDL code that I had provided, I did not use
> #import, yet instead used importlib() and added the cpp_quote() to provide
> the #include <adoint.h> header in the MIDL generated code.  How did the
> #import get in there from the code that I had provided?

> Regards,

> Joe



Fri, 10 Jan 2003 03:00:00 GMT  
 Returning ADO Recordset Problem

Greets,

    Here is sample IDL that I have used for testing:

---------------------------

import "oaidl.idl";
import "ocidl.idl";

cpp_quote("#include <adoint.h>")

[
 uuid(5846E4F9-8F2E-4203-83F8-D8B200415BC9),
 version(1.0),
 helpstring("ComTest 1.0 Type Library")
]
library COMTESTLib
{
 importlib("stdole32.tlb");
 importlib("stdole2.tlb");
    importlib("c:\winnt\system32\dllcache\msado21.tlb");

 [
  object,
        dual,
  uuid(7F594E14-82D4-48B8-9F63-553EF9FBDDEA),
  helpstring("IMyFirstInterface"),
  pointer_default(unique)
 ]
 interface IMyFirstInterface : IDispatch
 {
  [id(1), helpstring("method Method1")] HRESULT Method1([out,retval] int*
piValue);
 };

 [
  object,
        dual,
  uuid(7F594E14-82D4-48B8-9F63-553EF9FBDDEB),
  helpstring("IMySecondInterface"),
  pointer_default(unique)
 ]
 interface IMySecondInterface : IMyFirstInterface
 {
  [id(2), helpstring("method Method2")] HRESULT Method2([out,retval] int*
piValue);
 };

 [
  object,
  uuid(7F594E14-82D4-48B8-9F63-553EF9FBDDEC),
  dual,
  helpstring("IMyThirdInterface"),
  pointer_default(unique)
 ]
 interface IMyThirdInterface : IMySecondInterface
 {
  [id(3), helpstring("method Method3")] HRESULT Method3([out,retval] int*
piValue);
 };

 [
  object,
  uuid(7F594E14-82D4-48B8-9F63-553EF9FBDB5F),
  dual,
  helpstring("IMyRecord Interface"),
  pointer_default(unique)
 ]
 interface IMyRecord : IMyThirdInterface
 {
  [id(4), helpstring("method GetRecord")] HRESULT GetRecord([out,retval]
_Recordset* pRecordset);
 };

 [
  uuid(9B169538-6154-4BDA-AADE-86CF5669CE50),
  helpstring("MyRecord Class")
 ]
 coclass MyRecord
 {
  [default] interface IMyRecord;
 };

Quote:
};

-------------------

Regards,

Joe


Quote:
> Hi,

> I've been following this thread and tried to get something working.
> I had tried different ways to insert:
> - cpp_quote("#include <adoint.h>")
> - importlib("c:\program files\common files\system\ado\msado15.dll")
> but I kept on getting errors from the compiler.

> Where & how should I place these two lines?  I've run out of idea now.
> Thanks,

> Iwan
> PS: my IDL structure is as follow:
> --------------------------------------------------------------------------
>    import "oaidl.idl";
>    import "ocidl.idl";
>    [
>       object,
>       uuid(E72E4B92-9E7F-4F30-8EA3-E43576A681C5),
>       dual,
>       helpstring("ICustomer Interface"),
>       pointer_default(unique)
>    ]
>    interface ICustomer : IDispatch
>    {
>       [id(1), helpstring("method GetCustomer")] HRESULT GetCustomer([in]
> signed int CustomerId, [out,retval] _Recordset **pRSCustomer);
>    };
>    [
>       uuid(867D006E-58DB-414B-A916-88A1CB2BD640),
>       version(1.0),
>       helpstring("MOP Objects 1.0 Library")
>    ]
>    library MOPLib
>    {
>       importlib("stdole32.tlb");
>       importlib("stdole2.tlb");
>       [
>          uuid(C6C08E5D-C646-4E83-AC07-9B7FB9C53BAE),
>          helpstring("Customer Class")
>       ]
>       coclass Customer
>       {
>          [default] interface ICustomer;
>       };
>    };
> --------------------------------------------------------------------------
--
> ---



> > Greets,

> >     It would seem that one does not quite have the header files that
they
> > are using.  Note that in the IDL code that I had provided, I did not use
> > #import, yet instead used importlib() and added the cpp_quote() to
provide
> > the #include <adoint.h> header in the MIDL generated code.  How did the
> > #import get in there from the code that I had provided?

> > Regards,

> > Joe



Fri, 10 Jan 2003 03:00:00 GMT  
 Returning ADO Recordset Problem
That works!  So, my problem is not only where to put those 2 lines but also
the structure of the IDL itself (I was using it as provided default by ATL
Wizard).

Thanks,
Iwan


Quote:
> Greets,

>     Here is sample IDL that I have used for testing:

> ---------------------------

> import "oaidl.idl";
> import "ocidl.idl";

> cpp_quote("#include <adoint.h>")

> [
>  uuid(5846E4F9-8F2E-4203-83F8-D8B200415BC9),
>  version(1.0),
>  helpstring("ComTest 1.0 Type Library")
> ]
> library COMTESTLib
> {
>  importlib("stdole32.tlb");
>  importlib("stdole2.tlb");
>     importlib("c:\winnt\system32\dllcache\msado21.tlb");

>  [
>   object,
>         dual,
>   uuid(7F594E14-82D4-48B8-9F63-553EF9FBDDEA),
>   helpstring("IMyFirstInterface"),
>   pointer_default(unique)
>  ]
>  interface IMyFirstInterface : IDispatch
>  {
>   [id(1), helpstring("method Method1")] HRESULT Method1([out,retval] int*
> piValue);
>  };

>  [
>   object,
>         dual,
>   uuid(7F594E14-82D4-48B8-9F63-553EF9FBDDEB),
>   helpstring("IMySecondInterface"),
>   pointer_default(unique)
>  ]
>  interface IMySecondInterface : IMyFirstInterface
>  {
>   [id(2), helpstring("method Method2")] HRESULT Method2([out,retval] int*
> piValue);
>  };

>  [
>   object,
>   uuid(7F594E14-82D4-48B8-9F63-553EF9FBDDEC),
>   dual,
>   helpstring("IMyThirdInterface"),
>   pointer_default(unique)
>  ]
>  interface IMyThirdInterface : IMySecondInterface
>  {
>   [id(3), helpstring("method Method3")] HRESULT Method3([out,retval] int*
> piValue);
>  };

>  [
>   object,
>   uuid(7F594E14-82D4-48B8-9F63-553EF9FBDB5F),
>   dual,
>   helpstring("IMyRecord Interface"),
>   pointer_default(unique)
>  ]
>  interface IMyRecord : IMyThirdInterface
>  {
>   [id(4), helpstring("method GetRecord")] HRESULT GetRecord([out,retval]
> _Recordset* pRecordset);
>  };

>  [
>   uuid(9B169538-6154-4BDA-AADE-86CF5669CE50),
>   helpstring("MyRecord Class")
>  ]
>  coclass MyRecord
>  {
>   [default] interface IMyRecord;
>  };
> };

> -------------------

> Regards,

> Joe



> > Hi,

> > I've been following this thread and tried to get something working.
> > I had tried different ways to insert:
> > - cpp_quote("#include <adoint.h>")
> > - importlib("c:\program files\common files\system\ado\msado15.dll")
> > but I kept on getting errors from the compiler.

> > Where & how should I place these two lines?  I've run out of idea now.
> > Thanks,

> > Iwan
> > PS: my IDL structure is as follow:

> --------------------------------------------------------------------------
> >    import "oaidl.idl";
> >    import "ocidl.idl";
> >    [
> >       object,
> >       uuid(E72E4B92-9E7F-4F30-8EA3-E43576A681C5),
> >       dual,
> >       helpstring("ICustomer Interface"),
> >       pointer_default(unique)
> >    ]
> >    interface ICustomer : IDispatch
> >    {
> >       [id(1), helpstring("method GetCustomer")] HRESULT GetCustomer([in]
> > signed int CustomerId, [out,retval] _Recordset **pRSCustomer);
> >    };
> >    [
> >       uuid(867D006E-58DB-414B-A916-88A1CB2BD640),
> >       version(1.0),
> >       helpstring("MOP Objects 1.0 Library")
> >    ]
> >    library MOPLib
> >    {
> >       importlib("stdole32.tlb");
> >       importlib("stdole2.tlb");
> >       [
> >          uuid(C6C08E5D-C646-4E83-AC07-9B7FB9C53BAE),
> >          helpstring("Customer Class")
> >       ]
> >       coclass Customer
> >       {
> >          [default] interface ICustomer;
> >       };
> >    };

> --------------------------------------------------------------------------
> --
> > ---



> > > Greets,

> > >     It would seem that one does not quite have the header files that
> they
> > > are using.  Note that in the IDL code that I had provided, I did not
use
> > > #import, yet instead used importlib() and added the cpp_quote() to
> provide
> > > the #include <adoint.h> header in the MIDL generated code.  How did
the
> > > #import get in there from the code that I had provided?

> > > Regards,

> > > Joe



Fri, 10 Jan 2003 03:00:00 GMT  
 Returning ADO Recordset Problem


Fri, 19 Jun 1992 00:00:00 GMT  
 
 [ 18 post ]  Go to page: [1] [2]

 Relevant Pages 

1. Problem with IDL for COM server returning ADO disconnected Recordset

2. Problem with ADO recordsets of recordsets under MTS

3. error after returning ADO recordset

4. Returning an ADO Recordset to a client program

5. Returning ADO Recordset from functions

6. Is it possible to return ADO recordset from OLE DB Consumer ROWSET

7. Speed of ADO Recordset vs ADO Command in VC

8. ADO.Stream and ADO.RecordSet

9. Problems getting values from ADO Recordset

10. ADO Recordset Delete problem

11. Problem in UpdateBatch of ADO Recordset

12. Problem with ADO Recordset

 

 
Powered by phpBB® Forum Software