Re: Command Object and IColumnsRowset
- From: zunilp@xxxxxxxxx
- Date: 30 Apr 2007 09:12:21 -0700
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
.
- References:
- Command Object and IColumnsRowset
- From: mohan . gulati
- Command Object and IColumnsRowset
- Prev by Date: Command Object and IColumnsRowset
- Next by Date: Excel Oledb import into Datatable Skips Last Row
- Previous by thread: Command Object and IColumnsRowset
- Next by thread: Excel Oledb import into Datatable Skips Last Row
- Index(es):
Relevant Pages
|