1,105,578 Community Members

C# Sql back and forth data transfer

Member Avatar
kolibrizas
Junior Poster in Training
52 posts since May 2009
Reputation Points: 12 [?]
Q&As Helped to Solve: 2 [?]
Skill Endorsements: 0 [?]
 
0
 

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?

Member Avatar
Momerath
Senior Poster
3,831 posts since Aug 2010
Reputation Points: 1,327 [?]
Q&As Helped to Solve: 664 [?]
Skill Endorsements: 19 [?]
Featured
 
1
 

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)?

Member Avatar
kolibrizas
Junior Poster in Training
52 posts since May 2009
Reputation Points: 12 [?]
Q&As Helped to Solve: 2 [?]
Skill Endorsements: 0 [?]
 
0
 

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?

Member Avatar
mani-hellboy
Junior Poster in Training
69 posts since Feb 2012
Reputation Points: -10 [?]
Q&As Helped to Solve: 7 [?]
Skill Endorsements: 0 [?]
 
-1
 

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


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

Member Avatar
Merani
Newbie Poster
2 posts since Feb 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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# .....

Member Avatar
kolibrizas
Junior Poster in Training
52 posts since May 2009
Reputation Points: 12 [?]
Q&As Helped to Solve: 2 [?]
Skill Endorsements: 0 [?]
 
0
 

"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.

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: