Click here to Skip to main content
16,019,531 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have two tables.. A parent table...(Primary key) Category(CategoryId,CategoryName) and child table ..(Foreign key) Item(ItemId,ItemName,ItemCode,CategoryId)..having relationship between them..
when i delete records from application through a button click ...than record...should not be deleted...but should be hidden from application...and should be present in database table...and if i search the record from a textbox ...with the text changed event it should not be seen to the user...and also when a user tries to add data on the same hidden record ItemId...there should be a message ..that you cannot insert duplicate records....waiting for..your reply... thanks in advance....i have searched a lot but...nothing comes..handy....

What I have tried:

i worked with dml operation ...but this kind of situation iam facing for first time
Posted
Updated 8-Aug-16 1:07am
Comments
njammy 8-Aug-16 5:39am    
Please update your question with HTML markup, button events and code behind you have already got and I will help with this further detail.

1 solution

1. I would expect a data base table column flag for the deleted record, set this bit type e.g. deleted record value for this field = 1.

2. Your database query should exclude where deleted = 1 and thus only return "visible" non-deleted data.
e.g. MS SQL:
select * from table1 where not (deleted = 1)

3. On insert, first do query to check if the record exists using record parameters including deleted = 1
e.g. in MS SQL:
SQL
if not exists (select * from table1 where col1 = @col1 and col2 = @col2 etc...)
begin
  insert into table 1 @col1, @col2 etc...
end
else
begin
  update table1 set deleted = 0 where col1 = @col1 and col2 = @col2 etc...
end
 
Share this answer
 

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