Help: "Multiple rows were updated error' or is problem MFC's Update() 
Author Message
 Help: "Multiple rows were updated error' or is problem MFC's Update()

Hello,

I have an MFC application that is using dbase III dbf files through ODBC.
There is an index on field WORDN.  The following code adds  12 records or
edits 12 records.  All 12 records created will have the same Customer Number
and WORDN but not all records will have an Item Number etc.. When I go back
to edit existing records with Item numbers etc., there is no problem. There
is a problem when I go edit a record with  a blank Item Number.  I am just
modifying or editing an existing record's blank fields, but I get a
'Multiple rows were updated' error and the data entered for the row modified
is repeated for the rest of the rows with blank  Item number fields.

I am not entirely sure the problem is in my code,  it may be a problem with
MFC's  Update() function.

Thanks In Advance,
Cal

void CView::AddDets()
{
int i;
i=0;
if (bdetnot)
{
 Det.Open(CRecordset::snapshot,NULL);  // open recset if not already open
 bdetnot=FALSE;

Quote:
}

else
{
 Det.Requery();
Quote:
}

.
.
.
// code to get the document
.
.
  for (i = 0; i < 12; i++)  // records created (N) or edited (E)
  {
   if (bNew=="N")  // for New document, to create records
   {
    Det.AddNew();
    Det.SetFieldNull(NULL);
   }
   if (bNew=="E") // for Edit
   {
    Det.Edit();
   }
   Det.m_WORDN=m_whWORDN;
   Det.m_ITEMN = m_ITEMN[i];
   Det.m_DESCRIP = m_DESCRIP[i].Left(30);
   Det.m_QORD = m_QORD[i];
   Det.m_UNPRICE = m_UNPRICE[i];
   m_EXTENSION[i]=m_QORD[i]*m_UNPRICE[i];
   Det.m_EXTENSION = m_EXTENSION[i];

   if (bNew=="N")
   {
   UpdateData(FALSE);
   Det.Update();
   Det.MovePrev();
   Det.MoveNext();
   }
   if (bNew=="E")
   {
    Det.Update();      // When going back to edit one of the blank records
results in 'Muliple rows were updated' and the blank row to which changes
were made shows the same changes in the rest of the blank records
    Det.MovePrev(); Det.MoveNext();
    Det.MoveNext();
   }
  }
  bNew = "E";

Quote:
}



Wed, 24 Sep 2003 05:41:41 GMT  
 Help: "Multiple rows were updated error' or is problem MFC's Update()

Quote:

>Hello,

>I have an MFC application that is using dbase III dbf files through ODBC.
>There is an index on field WORDN.  The following code adds  12 records or
>edits 12 records.  All 12 records created will have the same Customer Number
>and WORDN but not all records will have an Item Number etc.. When I go back
>to edit existing records with Item numbers etc., there is no problem. There
>is a problem when I go edit a record with  a blank Item Number.  I am just
>modifying or editing an existing record's blank fields, but I get a
>'Multiple rows were updated' error and the data entered for the row modified
>is repeated for the rest of the rows with blank  Item number fields.

>I am not entirely sure the problem is in my code,  it may be a problem with
>MFC's  Update() function.

>Thanks In Advance,
>Cal

>void CView::AddDets()
>{
>int i;
>i=0;
>if (bdetnot)
>{
> Det.Open(CRecordset::snapshot,NULL);  // open recset if not already open
> bdetnot=FALSE;
>}
>else
>{
> Det.Requery();
>}
>.
>.
>.
>// code to get the document
>.
>.
>  for (i = 0; i < 12; i++)  // records created (N) or edited (E)
>  {
>   if (bNew=="N")  // for New document, to create records
>   {
>    Det.AddNew();
>    Det.SetFieldNull(NULL);
>   }
>   if (bNew=="E") // for Edit
>   {
>    Det.Edit();
>   }
>   Det.m_WORDN=m_whWORDN;
>   Det.m_ITEMN = m_ITEMN[i];
>   Det.m_DESCRIP = m_DESCRIP[i].Left(30);
>   Det.m_QORD = m_QORD[i];
>   Det.m_UNPRICE = m_UNPRICE[i];
>   m_EXTENSION[i]=m_QORD[i]*m_UNPRICE[i];
>   Det.m_EXTENSION = m_EXTENSION[i];

>   if (bNew=="N")
>   {
>   UpdateData(FALSE);
>   Det.Update();
>   Det.MovePrev();
>   Det.MoveNext();
>   }
>   if (bNew=="E")
>   {
>    Det.Update();      // When going back to edit one of the blank records
>results in 'Muliple rows were updated' and the blank row to which changes
>were made shows the same changes in the rest of the blank records
>    Det.MovePrev(); Det.MoveNext();
>    Det.MoveNext();
>   }
>  }
>  bNew = "E";
>}

Charles,
It's not you.  I got stuck with the exact same error message while
working with VB about 6 months ago and accessing a database.  I can't
remember exactly what was causing it.  It was a known bug.  There is a
work around:  I think you have to specify all of the key fields in

have time, I'll try to look it up.  Or do a power search on the error
message.  Let me know if this helps.

Greg.



Mon, 29 Sep 2003 06:53:37 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Q: Error message "Multiple rows updated"???

2. ODBC: "Multiple rows were updated" ERROR

3. single row updates effect multiple rows....

4. Can't update row data with SQLSetPos

5. CRecordset's Update seems "delayed"

6. Don't understand why I am getting the C2236 error

7. ending a blocing sockets call (am using MFC's CSocket class)

8. SQL/VC++ Updates: Can't update recordset

9. 'Hard Problem' Update CRecordSet

10. 'Hard Question' Update Problem

11. Problem for updating 'snapshot' recordset

12. I'am LOOKING 4 help w/ C++ PROGRAMING

 

 
Powered by phpBB® Forum Software