Multiple rows were updated
Wu Bin -- whelan@radiusplc.co.uk Tuesday, February 25, 1997 Environment: VC++ 4.1, Win95 I am using the following code to delete records in Access, but it always generate an error saying "Multiple rows were updated". Does anybody know why? Thanks in advance. ....... while (!m_srvTmpBTable->IsEOF()) { m_srvTmpBTable->Delete(); m_srvTmpBTable->MoveNext(); } ....... Bin Wu Radius Computer Service
Rondal C. Ellifritt -- rondal@mvision.com Wednesday, February 26, 1997 Wu Bin wrote: > > Environment: VC++ 4.1, Win95 > > I am using the following code to delete records in Access, > but it always generate an error saying "Multiple rows were > updated". Does anybody know why? Thanks in advance. > > ....... > while (!m_srvTmpBTable->IsEOF()) > { > m_srvTmpBTable->Delete(); > m_srvTmpBTable->MoveNext(); > } > ....... > > Bin Wu > Radius Computer Service ODBC doesn't keep track of what rows in your Access table correspond to what entries in your recordset. (I don't know a lot about DAO, but I suspect it works the same in this respect.) Thus, when you Delete() an entry in your recordset, ODBC has to figure out which rows in the Access table to delete by using the values of the fields in the recordset entry. If multiple rows in the table correspond to these field values you get multiple deletions. Rondal -- ____________________________________________________________________________ Rondal C. Ellifritt rondal@mvision.com When cryptography is outlawed, bayl bhgynjf jvyy unir cevinpl.
Mihir Dalal -- m_dalal@ECE.concordia.CA Tuesday, February 25, 1997 On 25 Feb 1997, Wu Bin wrote: > Environment: VC++ 4.1, Win95 > > I am using the following code to delete records in Access, > but it always generate an error saying "Multiple rows were > updated". Does anybody know why? Thanks in advance. > > ....... > while (!m_srvTmpBTable->IsEOF()) > { > m_srvTmpBTable->Delete(); > m_srvTmpBTable->MoveNext(); > } > ....... > > Bin Wu > Radius Computer Service > The reason, is that some of your records do indeed have duplicate values. When you delete a record which has one or more fields having duplicate values in multiple records, such an error message pops up. What is not clear to me is that although the message box says, that multiple fields were updated, infact it is not true. Only the record you attempt to delete gets deleted. Mihir. _________________________________________________________________________ Mihir Dalal, M.Engg. (Electrical) Student Department of Electrical and Computer Engineering Concordia University, Montreal, Canada http://www.ECE.Concordia.CA/~m_dalal/addr.html
Dan Kirby -- dkirby@accessone.com Wednesday, February 26, 1997 Hi, This is a result of using the cursor library and the fact that it uses SQL updates to perform updating. If you use dynasets, you will not see this problem because SQLSetPos will be used to perform direct updates on current record. Also, a faster way to delete a group of records is to perform a Cdatabase::ExecuteSQL call where you pass it a 'Delete from table where...." statement. --dan ---------- > From: Rondal C. Ellifritt> To: mfc-l@netcom.com > Subject: Re: Multiple rows were updated > Date: Wednesday, February 26, 1997 6:41 AM > > Wu Bin wrote: > > > > Environment: VC++ 4.1, Win95 > > > > I am using the following code to delete records in Access, > > but it always generate an error saying "Multiple rows were > > updated". Does anybody know why? Thanks in advance. > > > > ....... > > while (!m_srvTmpBTable->IsEOF()) > > { > > m_srvTmpBTable->Delete(); > > m_srvTmpBTable->MoveNext(); > > } > > ....... > > > > Bin Wu > > Radius Computer Service > > ODBC doesn't keep track of what rows in your Access table correspond to what > entries in your recordset. (I don't know a lot about DAO, but I suspect it > works the same in this respect.) Thus, when you Delete() an entry in your > recordset, ODBC has to figure out which rows in the Access table to delete > by using the values of the fields in the recordset entry. If multiple rows > in the table correspond to these field values you get multiple deletions. > > Rondal > -- > ____________________________________________________________________________ > Rondal C. Ellifritt rondal@mvision.com > When cryptography is outlawed, bayl bhgynjf jvyy unir cevinpl.
Wu Bin -- whelan@radiusplc.co.uk Thursday, February 27, 1997 Mihir Dalal: >> Environment: VC++ 4.1, Win95 >> >> I am using the following code to delete records in Access, >> but it always generate an error saying "Multiple rows were >> updated". Does anybody know why? Thanks in advance. >> ....... >> while (!m_srvTmpBTable->IsEOF()) >> { >> m_srvTmpBTable->Delete(); >> m_srvTmpBTable->MoveNext(); >> } >> ....... >The reason, is that some of your records do indeed have duplicate values. >When you delete a record which has one or more fields having duplicate >values in multiple records, such an error message pops up. > >What is not clear to me is that although the message box says, that >multiple fields were updated, infact it is not true. Only the record you >attempt to delete gets deleted. > >Mihir. Thanks. Yes, there are indeed some records in the DB that do have duplicate values and they are NOT deleted after the call. The deleting procedure stops after the error generates. How could I delete all the records? bin Wu,
Become an MFC-L member | Вернуться в корень Архива |