So I am trying to make let's say, a chat software. For this example there will be two users X and Y and the Database named DB:

1. Both X and Y are connected to DB
2. X sends a message through a form by clicking submit,
3. the message is then recorded into DB

4.
id|from|to|message
17|X |Y |Hello!

5. DB instantly sends sql result
6. Y sees "Hello!" on his screen.

The only, but the most important part is #5. How to do that?

Triggers is how you would do this. If you are using SQL Server it is possible to write modules in C# that can be executed by the server. It would be easier just to have the client poll the DB for info.

I do have to ask, though, why save the message in the DB? Have you considered a 3-tier solution (Server, Client, DB)?

commented: Many suggestions on how to solve a problem. +2

Triggers is how you would do this. If you are using SQL Server it is possible to write modules in C# that can be executed by the server.

I am starting to google this in a second.

It would be easier just to have the client poll the DB for info.

You mean like client to send query for new info every 1 second or so? If yes, then it doesn't really suit me.

I do have to ask, though, why save the message in the DB? Have you considered a 3-tier solution (Server, Client, DB)?

Can you please provide me with a simple drawn/written scheme on how this would work?

use trigger in database and WCF in front end that will really help you


---try code your self---
-----you learn more-----

If both X and Y are polling the database at frequent intervals like say every 5 second, then you would not need to write triggers. AJAX could get the data to either from DB.
You may refer to this artiele as a starting point.
On a side note, you have not indicated if this is web based or a windows based application. Both can be in C# .....

"5. DB instantly sends sql result"
It obviously states that AJAX is not capable to solve that. But thanks for trying to help. Maybe any more ideas? And I do not care whether for web or windows based :) Both will be fine.

Edit: Thanks for a link. I had already reviewed it tho.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.