Jump to content
  • Advertisement
Sign in to follow this  
da_cobra

ADO : deleting

This topic is 4889 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


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!