Click here to Skip to main content
15,031,208 members
Please Sign up or sign in to vote.
1.47/5 (3 votes)
See more: , +
I have done coding for unread messages and its count from DB. I dont know how to check whether the user has read that message or not. How to code for that in c#. Suggest me....
Nnorss 21-May-13 3:32am
Give more informations about your database and your tables content please.
sukumari1 21-May-13 4:02am
It's like a mail. For an example, if there are 200 messages it displays Unread msgs (200). If user reads a mail it decreases to 199. I dont know how to check if user has read the mail or not. How to get the status if message has been read...
Sunasara Imdadhusen 21-May-13 3:39am
Not clear at all
Nnorss 21-May-13 4:05am
How is the structure of your database? does the table_messages have a column readStatus or something like that...?
sukumari1 21-May-13 4:08am
Yes. Columns are:
ID, Usermsg, UserUniqueId, Status.

Initially i have set status as 'No' to all the messages.
Nnorss 21-May-13 4:20am
Check the solution please.

You must first add a new bit(boolean) column to your Table_Messages, you can name it readStatus. Make the default value to false(unreaded), and chagne it to true when the message become readed. Then you can use a command to show the messages that have Status==false.
You can do something like this:
using (SqlConnection conn = new SqlConnection(connString))
      SqlCommand cmd = new SqlCommand("SELECT * FROM messages 
                                       WHERE Status = false", conn);
            //code to show result of the command
        catch (Exception ex)

Wish this can help you! Good luck.
sukumari1 21-May-13 4:38am
Message for users almost appears in grid view right ?!
There are an event when click of selected row of gridview you can update status in table to be true that means message has been read.

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