CompuServe Thread

Recordset.Delet

4 messages in this thread
#30332From: Israel BurmanJul 8, 1994 6:32 PM
The Recordset.Delete function is defined in the manual as having a BOOL return value, but it is actually a void function as you can see in afxdb.h. How can I know if the delete function was succesfull? I tryied to delete records from a table using CRecordset.Delete function. I got the message: Multiple rows were updated when trying to delete the first record, and after this, the message bellow for the next records: No rows were affected by the update or delete operation. What is wrong? Thanks Israel
#30419From: Roby GamboaJul 10, 1994 2:28 PM
I found that the query you used to obtain the record you wish to delete *must* be indexed on a unique field. If there is any ambiguity regarding the unique nature of the record in the return set (whether or not it really is unique), you will receive the 'Multiple rows were updated' message, which is incorrect: no update took place, the operation failed. What worked for us was to designate a 'dummy' counter field and use it as the primary key for the table. After including the appropriate member variables and RFX routines and updating the m_nFields variable to reflect the increase in the number of columns, our queries worked fine. There was no need to change the queries: the proper record was returned, but now was uniquely specified by the counter field…ambiguity (whether possible or actual) was resolved. Roby
#30510From: Israel BurmanJul 11, 1994 10:22 AM
Roby Thanks for your answer. In my case, I'm just begining my tests with odbc and the table I used for testing it have not index at all, but I have records that are replicated (ave the saem value in all fields). In the other side I imagine that if I use the Recordset.delete function it should work for the record that is selected independent if there are other records with same values. But anyways, your information is usefull, I will try to set diferent values on the records just to see what happens. Thanks Israel
#30501From: Ronald LaeremansJul 11, 1994 9:37 AM
Israel, What probably happened is that you did not select all the coulumns (fields) that make up a specific row. Even if you need only a few fields from the select, you still need to include all the fields making up a unique index. The cursor library will turn a Recordset delete into a "searched delete": "delete from Mytable where field1=xxx, field2=yyy, field3=zzz, …". With field2, field2 … being the columns you bound to the recordset. -Ronald-