[Sorry, the email address of the previous posted msg was wrong....]
Hello,
I have an openned (disconnected) ADO RecordSet and I need to add an extra
field to it.
To do so, I have created a new disconnected Recordset and I trying to copy
the definition/data of the first Recordset and add the extra field. I'm
using the Append method.
My problem is the following:
I'm getting error 0x80040e21 [in Field20::PutValue method] when copying a
particular field data from source to destination.
By playing with the 4th param of Append() [adFldUnspecified,
spRsSrc->GetFields()->Item[x]->Attribute, ...], I managed to have the error
on differant fields.
Am I doing something wrong?
Jose
I'm using Windows2000 , VC++ 6 sp4 and MDAC 2.6
Here is an extract of my code:
==============================
_RecordsetPtr spRsDest;
spRsDest.CreateInstance(__uuidof(Recordset));
long nlimit = spRsSrc->GetFields()->Count;
// Copy struct of existing Rset
for (long x = 0; x<nlimit; x++)
spRsDest->Fields->Append (spRsSrc->GetFields()->Item[x]->Name,
spRsSrc->GetFields()->Item[x]->Type,
spRsSrc->GetFields()->Item[x]->DefinedSize,
adFldUpdatable,
vtMissing);
// Open our new Rset (in disconnected mode)
spRsDest->Open(vtMissing, vtMissing, adOpenDynamic, adLockBatchOptimistic,
adCmdText);
// Copy data content
while(spRsSrc->adoEOF == false)
{
spRsDest->AddNew();
for (long x = 0; x<nlimit; x++)
{
// Copy data
spRsDest->GetFields()->Item[x]->Value =
spRsSrc->GetFields()->Item[x]->Value; // ERROR thrown here!!!!!!
// add value for my new field as needed...
}
spRsSrc->MoveNext();
Quote:}