Re: Command Object and IColumnsRowset



Hi Mohan,
I am not comfortable with ATL. But I tried the same thing using OleDB
interfaces.
This is what I Did
1. Set DBPROP_IColumnsRowset to trur for command object
2. Then QueryInterface with IID_IColumnsRowset using IRowset object
3. Then set optional columns needed from GetColumnsRowset.
like DBID availableColumnDBIDs[1];
availableColumnDBIDs[0] = DBCOLUMN_BASETABLENAME;
4. IColumnsRowset::GetColumnsRowset(NULL, 1, availableColumnDBIDs,
IID_IRowset, 0, 0, (IUnknown **)pColumnsRowset);

5. Using this pColumnsRowset retrieve rows..

It worked for me... For some providers it won't support
IColumnsRowset. In such cases you can try using
IColumnInfo::GetColumnInfo. This also will give almost same
information.

Note : Oracle provider will not give you BASE TABLE name..
REgards
zunilp
On Apr 30, 6:36 pm, mohan.gul...@xxxxxxxxx wrote:
Hi,

I am trying to use ADO to retrieve information about a SQL Statement
that I am executing. In my searches on MSDN I came across the Command
Object and saw that it had dynamic properties to retrieve information
like the "BASE Table name" or "BASE column name". This information
would be very useful to me. But honestly I could not figure out how
to get this to work at all!

Here is some code that I wrote in C++.

///////////////////////////////////////////////////////////////////////////­////////////////////////////////////////

MYADO::PropertyPtr pProperty =
pCommandPtr->GetProperties()-

GetItem( CComVariant(_T("IColumnsRowset")));

VARIANT nVariant = pProperty->GetValue();
if ( ( nVariant.vt == VT_BOOL ) && ( V_BOOL( &nVariant ) ==
VARIANT_TRUE ) )
{
CComQIPtr< IColumnsRowset > pMyColumnInfo =
pCommandPtr.GetInterfacePtr();
if ( pMyColumnInfo != NULL )
{
// Get the rowset information
}

}

///////////////////////////////////////////////////////////////////////////­////////////////////////////////////////

But pMyColumnInfo is always NULL?

I really need an example that would show me how to from the Command
Object extract detailed information about each column in the
statement.

For me this would be similar to the ODBC methods SQLGetColumnAttr.

Regards,
Mohan


.



Relevant Pages

  • How To Do It Faster?!?
    ... I had to kill Python after having issued that command because ... In my first mail, I said I have to work with a BIG directory (more than ... TB) and I need to retrieve information when they become available (I put ... this info on a wxPython ListCtrl). ...
    (comp.lang.python)
  • Command Object and IColumnsRowset
    ... I am trying to use ADO to retrieve information about a SQL Statement ... CComQIPtrpMyColumnInfo = ... I really need an example that would show me how to from the Command ...
    (microsoft.public.data.ado)
  • Command Object and IColumnsRowset
    ... I am trying to use ADO to retrieve information about a SQL Statement ... CComQIPtrpMyColumnInfo = ... I really need an example that would show me how to from the Command ...
    (microsoft.public.data.oledb)
  • Between Expression searching between alpha / #s - Using Access Form
    ... with a command button which will search for information and put this ... EXAMPLE OF FORM LAYOUT: ... (LABEL OR TEXT BOX HERE) -- the information now shows ...
    (microsoft.public.access.queries)
  • Re: "Select All" control in continuous form
    ... I do have one other question - when it runs I get a standard message saying ... I have a continuous form which users can input the name of an activity ... One thing you could try is to use an SQL statement ... The Click event is the event that fires when a command button is clicked. ...
    (microsoft.public.access.forms)