• Advertisement

• ### Popular Now

• 11
• 9
• 10
• 9
• 10
• Advertisement
• Advertisement
• Advertisement

# ADO : deleting

This topic is 4707 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

## Recommended Posts

Hello, I have an application with a listview on it, filled with the names of the persons of my records + their IDs. If I click on a person and press on the delete button, I pass on the ID to that function and delete the record with that ID. Now I can do it 2 ways : with the normal Delete() function or with an SQL statement. But in both cases I have some problems... Delete() : If I want to use this function I try to do it this way :
CString strFilter  = "IDPersoon = " + strID ;

varFilter = strFilter ;

m_pRSPersonen->PutFilter(varFilter) ;

try
{
m_pRSPersonen->Delete(adAffectCurrent) ;
m_pRSPersonen->MoveFirst() ;
}
catch(_com_error &e)
{
AfxMessageBox(e.Description()) ;
return S_FALSE ;
}


problem : After the delete I only had I record, because of the filter, so I get an EOF error with SQL-statement :
CString strSQL, strID ;
strID.Format("%d", lnID) ;

strSQL = "Delete FROM Personen where IDPersoon = " + strID ;

try
{
m_pConn->Execute((_bstr_t)strSQL, NULL, adExecuteNoRecords) ;
}
catch(_com_error &e)
{
AfxMessageBox(e.Description()) ;
}


Problem : My listview is now filled with 2 of the same records, it seems that the last record is now copied onto the deleted record, BUT it doesn't exist anymore. If I restart my application, the deleted record isn't there anymore (as it should offcourse) and the "copied" record is also dissapeared. So my guess is I should do a requery or so?!? In both cases, de records are deleted, but it's afterwards that I get those 2 problems. If I get 1 problem solved I can use that solution then. So I hope some1 sees what I'm doing wrong... TIA

#### Share this post

##### Share on other sites
Advertisement

• Advertisement