Re: Command Object and IColumnsRowset
- From: mohan.gulati@xxxxxxxxx
- Date: 2 May 2007 08:30:15 -0700
On Apr 30, 6:12 pm, zun...@xxxxxxxxx wrote:
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
Hi zunilp,
Like I said I have not had too much experience at this level, but I
have gotten to the point now where I think what I should be able to do
is Query the Interface of a Recordset or Command Object from ADO and
retrieve the IColumnsRowset or IColumnInfo object. However I have not
successfully been able to do this. In fact its seems really strange
that there are dynamic properties that return tree for the ADO Command
and RecordSet object BUT you get nothing back when you query the
interface.
I do not know if i am missing something here.
Here is what I am trying now:
IColumnsInfo * pRs = NULL;
HRESULT hr = pCommandPtr->QueryInterface(IID_IColumnsInfo, (void
**)&pRs);
if ( pRs )
{
// Use the IColumnsInfo object ptr
}
Any clues what I can do?
I understand that once I have the IColumnsInfo or IColumnRowset I can
extract column level information for the SQL Statement, but first I
need to know how to bridge the ADO and OLE DB gap.
Thank again,
Mohan
.
- Prev by Date: Re: asychronous OLEDB
- Next by Date: Re: asychronous OLEDB
- Previous by thread: oledb and dates in vb.net 2003
- Next by thread: Re: Query regarding Multiple parameter set using OLEDB
- Index(es):
Relevant Pages
|
|