Click here to Skip to main content
15,894,907 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
I am developing an asp.net application which send letters to different users.

I have created one sql table in which letters is stored(letter can be sent to more than one users at the same time) .

i have implemented but the the problem is when i m storing letter in DB i set its status "Unread".

when user open his profile unread letters for particular user is shown but when he mark the status as "READ" then the status updated to all users AS "READ" in DB.... and others cannot view their letters...

kindly propse a solution for that problem
THANKS in advance!
Posted
Updated 29-May-15 3:52am
v2
Comments
[no name] 29-May-15 9:44am    
You need to add a where clause to your query.
Prasad Avunoori 29-May-15 9:46am    
Hi,
check your SQL Update statement. I think you missed to write WHEREcondition.
Muhammad Maaz 29-May-15 10:39am    
Users should be able to view their letters in any case Read or Unread and secondly you have to narrow down your update statement for a particular user so that it may not effect other users' letters.

1 solution

So, it seems like when you are updating, you forgot to add the condition for the particular user.

You need to form the query like below.
SQL
UPDATE Letter
SET Status = 'READ'
WHERE UserId = @UserId

Here @UserId is the parameter. You should provide the current UserId value to it.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 29-May-15 10:45am    
May be your answer is correct, but I'm looking at it in amazement: how do you know what the inquirer wrote? Nothing is shown in the question.
—SA
Haha. We have faced this kind of issues many times. I have seen one instance, when one of colleagues updated all phrase translation records instead of one due to no "where" condition. :)

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