Two columns with same name in ADO Recordset Fields collection

  • Thread starter Thread starter Sandeep Limaye
  • Start date Start date
S

Sandeep Limaye

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
 
Hi Sandeep,

Do you know that you are sending an Ado question to an AdoNet newsgroup.

microsoft.public.data.ado

Is by instance an ADO classic newsgroup.

I hope this helps?

Cor
 
yes, sorry about bothering you all, and thanks for pointing me to the
correct newsgroup.

Regards,
Sandeep
 
¤ 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?

Not sure how you are getting two columns with the same name in an ADODB Recordset but there is no
way that I am aware of to add them via the Fields collection.


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
Back
Top