Click here to Skip to main content
15,889,176 members
Please Sign up or sign in to vote.
3.33/5 (3 votes)
See more:
Scenario!
I have loaded a record on screen.
Now i want to delete this record.
Before deleting this record i made a fetch to see wether this record exists in db or not.
If exists then i do the following code.

VB
CookieSubprodContext.DeleteObject(currentProductCategory)
intRowsAffected = CookieSubprodContext.SaveChanges()
ProductCategoryList.Remove(currentProductCategory)
currentProductCategoryIndex = ProductCategoryList.Count - 1
PopulateFields()
MsgBox("Record deleted")


and if this record does not exists in db i am doing this!

VB
CookieSubprodContext.Detach(currentProductCategory)
ProductCategoryList.Remove(currentProductCategory)
currentProductCategoryIndex = ProductCategoryList.Count - 1
PopulateFields()


Just want to know is my approach is OK! if not then what is the best resolution for this!
Posted
Updated 6-May-11 2:41am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900