Click here to Skip to main content
15,910,872 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
I am having one concept i.e.

[1] 2 combo boxes combo1(shows items from database) , combo2(shows marked as deleted items) n 1 listview control(shows items details) on form.

[2] I select an item from combo1 n whenever I clicked delete button the item from combo1 gets removed n will be appeared in combo2 also removed from listview control but not deleted from the database itself.....

[3] I hv tried lots of tricks bt no one gives appropriate result

plz help.......
Posted

1 solution

How to mark items as deleted not originally delete from database?
Define a new column of bit type in your database for ever record in a table.
Bit field will hold either true or false. By default, set this flag value as false to indicate active and valid. Once you delete it from frontend, set this field to 'true' to mark as deleted.

Now, during data retrieval from DB, use this field as one of the WHERE clause condition, ex:
C#
-- IsDelete is the BIT field defined
SELECT * FROM myTable WHERE IsDelete = false
 
Share this answer
 
Comments
surkhi 16-Mar-13 5:06am    
I don't understand.....
I hv to add field in table n in front-end also?
I hv tried this one bt it's not working....

Private Sub BtnDelete1_Click()
Combo3.AddItem "" & Combo4.Text & ""
If Combo4.ListCount Then Combo4.RemoveItem Combo4.ListIndex
MsgBox "Record Deleted Successfully ", vbInformation, "Deletion Successful"
End Sub
Sandeep Mewara 16-Mar-13 5:14am    
Which part of the answer was unclear?
You need to add a field in database table. When you retrieve data, just get the data that is not marked as deleted. No change in frontend - everything as is. Only change in DB table and the query to get data.
When marking anything deleted in frontend, update that field in DB as deleted for that record.
surkhi 16-Mar-13 5:21am    
ok.....
so I don't need to use removeitem property of combo box.
thanx
Sandeep Mewara 16-Mar-13 5:24am    
You don't need to if you are re-fetching/binding the data after delete. If you don't rebind then you need to do removeitem and also set isdeleted flag in DB such that in future when you retrieve data you don't get that data.
surkhi 16-Mar-13 5:29am    
ya i'll re-fetch that data in future
thanx

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