Two columns with same name in ADO Recordset Fields collection

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Sandeep Limaye (sandeep_limaye_at_persistent.co.in)
Date: 08/03/04


Date: Tue, 3 Aug 2004 15:01:02 +0530

Hi,

Is there any way that I can add multiple columns with the _same name_ into
the Fields collection of an ADO recordset? I am fetching data into an
OracleDataReader through the usage of ODP.NET, and I want to create and
populate a Recordset from it to be returned to my COM clients.

At present, for a query such as "SELECT id, id from table1" the
OracleDataReader does contain two columns with the same name "id", but when
I try to populate the fields collection of a recordset, while inserting the
second column using Append() method, it gives the following error:

<snip>
Object is already in collection. Cannot append. at
ADODB.Fields.Append(String Name, DataTypeEnum Type, Int32 DefinedSize,
FieldAttributeEnum Attrib, Object FieldValue) at
ADODB.InternalFields.Append(String Name, DataTypeEnum Type, Int32
DefinedSize, FieldAttributeEnum Attrib, Object FieldValue)
</snip>

MSDN of course says that you can't append two columns with the same name to
the fields collection. But when I run the same query directly using MS ADO
and OleDb, the recordset returned to me _does_ contain two columns with the
same name. Is there anything that I am missing, or any special flags that
need to be set to allow for such duplicate column names?

Thanks in advance,
Sandeep



Relevant Pages

  • Re: Two columns with same name in ADO Recordset Fields collection
    ... the Fields collection of an ADO recordset? ... populate a Recordset from it to be returned to my COM clients. ... I try to populate the fields collection of a recordset, ... DefinedSize, FieldAttributeEnum Attrib, Object FieldValue) ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: run-time error 3265 Item Not Found in This Collection
    ... Your recordset has only one field, and the Fields collection is zero-based. ... > Set dbMain = CurrentDb ... > Set rsMain = dbMain.OpenRecordset ...
    (microsoft.public.access.modulesdaovba)
  • Re: Help with understanding order of For Each Control
    ... The whole purpose of a recordset is to support operations on the Fields collection. ... A Collection object is an ordered set of items that can be referred to as a unit. ...
    (comp.databases.ms-access)
  • Re: display recordset values
    ... >>> assign the values in the record to PName? ... But I'm not sure how to use the recordset. ... >>> Public Function PNameAs String ... >> The Recordset Object has a Fields collection that holds the results. ...
    (microsoft.public.vb.database.ado)
  • Re: Using WSH to populate a pivot cache with an ADO recordset
    ... I've tried this method and it works OK from WSH. ... However, in this case, I still need to be able to populate the pivot cache ... using an ADO recordset, because I've run previous statements on the ADO data ...
    (microsoft.public.excel.programming)