Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an application for chatting when the user add a word in the database a notification should come to me that a new item is added in the database and it should happen at the sametime when someone have added anything to a particular database. It should be by using c# and .net .

Actually what i need is i need a technique to execute to find the new item which added in the database and it should occur at the same time when someone added an item in to my database.

My Table will be like this

From | To | Text
xx | yy | hellow
zz | uu | Hai

if xx added a text hellow to yy

yy should get the text which xx have added to the database at the same time xx adding.
Posted
Updated 25-Oct-13 5:28am
v4
Comments
When the record is added to the Database, just add notification codes after that. What is the problem?

You can use this after your insertion code:
C#
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Record Inserted Successfully')", true);
 
Share this answer
 
Comments
Tom Marvolo Riddle 25-Oct-13 9:08am    
@codestar007:I guess he is searching for something like trigger
You will create trigger on your table. When any new record is inserted to that table then the trigger is fired automatically and inside that trigger you can get the value which is inserted and do anything with this value.
Please read the following trigger related article
Triggers -- Sql Server[^]
 
Share this answer
 
As you tagged your question with Javascrip, I assume you want to make a web application. Well, part of it will depend on the framework you use (WebForms, Web Pages, MVC...), but the key point is how you are able to notify a state-less client (a html/javascript application part running in a browser is such a client).
If you can ensure, that all client run HTML5 (Websockets) enabled browser, you can take this approach: HTML5 Real-Time Chat with Websockets, jQuery, and Spike-Engine[^]. If not, you have to consider some automatic polling from client side (this won't be instantaneous, but can be quite quick - with regards to your network bottlenecks). This polling can be simply done with an ajax call.
Here you have a library that can handle this transparently from your application's point of view: SignalR[^]
 
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