Copying ADO RecordSet Using Append() -->error 0x80040e21 !!!

Copying ADO RecordSet Using Append() -->error 0x80040e21 !!!

Post by José Joy » Wed, 30 May 2001 17:08:26



[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:}

 
 
 

Copying ADO RecordSet Using Append() -->error 0x80040e21 !!!

Post by yhhuan » Thu, 31 May 2001 14:43:53


Not sure of the reason. In oledberr.h, 0x80040E21L is defined as:
//
// MessageId: DB_E_ERRORSOCCURRED
//
// MessageText:
//
//  Multiple-step operation generated errors. Check each status value. No
work was done.
//
#define DB_E_ERRORSOCCURRED              ((HRESULT)0x80040E21L)

Try to revise the code as spRsDest->GetFields()->Item[x]->Value =
..(value) and then test it first.

yhhuang
ICQ:91074870

 
 
 

Copying ADO RecordSet Using Append() -->error 0x80040e21 !!!

Post by José Joy » Fri, 01 Jun 2001 06:27:51


To get more info, I have place the following code after the error is issued:

                    long abc = spRsDest->GetFields()->Item[x]->Status;

If I put as 4th param of Append():  "adFldUpdatable", the error is
adFieldDataOverflow

If I put as 4th param of Append():
"(FieldAttribu*um)spRsDal->GetFields()->Item[x]->Attributes", the error
is adFieldDataOverflow

According to the documentation, this means:
adFieldDataOverflow    Indicates that the data returned from the provider
overflowed the data type of the field
adFieldIntegrityViolation Indicates that the field cannot be modified
because it is a calculated or derived entity



Quote:> [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();
> }

 
 
 

Copying ADO RecordSet Using Append() -->error 0x80040e21 !!!

Post by Jose Joy » Fri, 01 Jun 2001 20:07:33


In fact the original record set is build by taking information from a SQL
Server 7.0 dB. The query made returns for some fields  constant values (eg:
8, "Dummy Info").

Then, the idea is to extend the content of the RS by adding an new field.
That'sthe reason why I'm making a carbon copy of the original RS (including
structure and contents).
It seems that the 4th param of Append() is making the trouble.
In order to get more detailled about the error, I have added after the error
is thrown:
    long abc = spRsDest->GetFields()->Item[x]->Status;

If I put as 4th param of Append():
"(FieldAttribu*um)spRsDal->GetFields()->Item[x]->Attributes", the error
is adFieldDataOverflow
If I put as 4th param of Append(): "adFldUpdatable", the error is
adFieldIntegrityViolation.

To my understanding, I'm duplicating to structure when I use the append
method. Therefore, I do not undertand why I got such an error.
This is specially true for the "adFieldIntegrityViolation" error when the
adFldUpdatable" flag is set. In this situation, I'm asking to be able to
update this field!!

Thanks,
Jose


Quote:> Not sure of the reason. In oledberr.h, 0x80040E21L is defined as:
> //
> // MessageId: DB_E_ERRORSOCCURRED
> //
> // MessageText:
> //
> //  Multiple-step operation generated errors. Check each status value. No
> work was done.
> //
> #define DB_E_ERRORSOCCURRED              ((HRESULT)0x80040E21L)

> Try to revise the code as spRsDest->GetFields()->Item[x]->Value =
> ..(value) and then test it first.

> yhhuang
> ICQ:91074870

 
 
 

Copying ADO RecordSet Using Append() -->error 0x80040e21 !!!

Post by Jose Joy » Fri, 01 Jun 2001 21:51:39


Hello,

Here is the detail of error
1) with 4th param set to
(FieldAttribu*um)spRsSrc->GetFields()->Item[x]->Attributes
name = Refund
Src type = dest type = 131    adNumeric
Src size=dest size = 19
Src attribut = 120
dest attribut = 124
dest status = 6                adFieldDataOverflow
Value containded into SRC: 9090

1) with 4th param set to adFldUpdatable
name = "TMS Control Total"
Src type = dest type = 131    adNumeric
Src size=dest size = 19
Src attribut = 120
dest attribut = 20
dest status = 10            adFieldIntegrityViolation
Value containded into SRC: <NULL>

Thank,
Jose


Quote:> Not sure of the reason. In oledberr.h, 0x80040E21L is defined as:
> //
> // MessageId: DB_E_ERRORSOCCURRED
> //
> // MessageText:
> //
> //  Multiple-step operation generated errors. Check each status value. No
> work was done.
> //
> #define DB_E_ERRORSOCCURRED              ((HRESULT)0x80040E21L)

> Try to revise the code as spRsDest->GetFields()->Item[x]->Value =
> ..(value) and then test it first.

> yhhuang
> ICQ:91074870

 
 
 

Copying ADO RecordSet Using Append() -->error 0x80040e21 !!!

Post by yhhuan » Sat, 02 Jun 2001 14:45:56


Can't fine the reason in terms of this info. Have you tried with Platform
SDK OleDB sample RowsetViewer?

yhhuang
ICQ:91074870

 
 
 

Copying ADO RecordSet Using Append() -->error 0x80040e21 !!!

Post by Jose Joy » Sat, 02 Jun 2001 18:53:07


Thanks,

By adding
if ((spRsSrc->GetFields()->Item[x]->Type == adNumeric)  ||
    (spRsSrc->GetFields()->Item[x]->Type == adSmallInt))
   {
    spRsDest->GetFields()->Item[x]->NumericScale =
spRsSrc->GetFields()->Item[x]->NumericScale;
    spRsDest->GetFields()->Item[x]->Precision =
spRsSrc->GetFields()->Item[x]->Precision;
   }

It works!


Quote:> Can't fine the reason in terms of this info. Have you tried with Platform
> SDK OleDB sample RowsetViewer?

> yhhuang
> ICQ:91074870

 
 
 

1. Copying ADO RecordSet Using Append() -->error 0x80040e21 !!!

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();

2. Passing Parameters from Access to SQL Server view

3. Datatype; Float datatype can not work in my SQL Server important

4. Newbie - FileMaker DB ?

5. ADO Error 0x80040E21 when asigning adVarChar field

6. help !!

7. Copy a record and then append it to the recordset

8. Informix and ADO support and ADO->ODBC->Informix error

9. ADO:Recordset->Move error!