Link to home
Start Free TrialLog in
Avatar of madhtrr
madhtrr

asked on

C++ ADO OpenSchema

// lpcn->OpenSchema returns adErrInvalidArgument
//
// I need to be able to to this, I don't want to import msado15.dll
// because i don't want exceptions thrown.
//
// I've been researching this for 2 DAYS.  How do I make it work?

ADORecordset* ADOListTables(ADOConnection* lpcn){
    HRESULT hr = S_OK;
    ADORecordset* lprs = 0;

    VARIANT vtempty = {VT_EMPTY};
    hr = lpcn->OpenSchema(adSchemaTables,vtempty,vtempty,&lprs);

    // hr is adErrInvalidArgument and lprs is NULL.

    return lprs;
};
Avatar of jkr
jkr
Flag of Germany image

See http://support.microsoft.com/kb/182831 ("HOWTO: Using the ADO OpenSchema Method from Visual C++") for an example on how to use that method. You will find more at http://msdn2.microsoft.com/en-us/library/ms676557.aspx ("OpenSchema Method Example (VC++) ")
Avatar of madhtrr
madhtrr

ASKER

Hi jkr!  hope your doin good:)

I saw both of those in my travels.  they both import msado15.dll, use a com wrapper, and reqiure a try catch blocks to catch 'exceptions'.  I am using the method from the raw ADOConnection pointer:

HRESULT OpenSchema(long, VARIANT ,VARIANT ,ADORecordset**)

not

_RecordsetPtr OpenSchema(long, /*optional*/ VARIANT, /*optional*/ VARIANT)

 like in the examples.  I made those work by just leaving out the optionals. I cannot do that without the wrappers in msado15.dll

There are 3 ways to do it, I am using the one that reqires the most coding but gives the most control instead of the ADODB wrappers ...

ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of madhtrr

ASKER

you ROCK.

Not only did you solve the problem, you have taught me that I need read the documentation THOROUGHLY, even if it is not exactly the same as what I am doing ATM:)