We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,344 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

C# Sql back and forth data transfer

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?

4
Contributors
5
Replies
1 Week
Discussion Span
1 Year Ago
Last Updated
6
Views
kolibrizas
Junior Poster in Training
52 posts since May 2009
Reputation Points: 22
Solved Threads: 2
Skill Endorsements: 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. 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)?

Momerath
Senior Poster
3,729 posts since Aug 2010
Reputation Points: 1,322
Solved Threads: 624
Skill Endorsements: 13

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?

kolibrizas
Junior Poster in Training
52 posts since May 2009
Reputation Points: 22
Solved Threads: 2
Skill Endorsements: 0

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


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

mani-hellboy
Junior Poster in Training
69 posts since Feb 2012
Reputation Points: 0
Solved Threads: 7
Skill Endorsements: 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# .....

Merani
Newbie Poster
2 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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.

kolibrizas
Junior Poster in Training
52 posts since May 2009
Reputation Points: 22
Solved Threads: 2
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0884 seconds using 2.74MB