数据库发生更改时更新用户界面 [英] Update User Interface when there is change in database
本文介绍了数据库发生更改时更新用户界面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发应用程序。使用C#和SQL Server 2005,
我要做的是当数据库发生变化时更新用户界面,
假设,表格上有数据网格..
不同计算机上的两个不同用户 - 同时打开表单。
one用户编辑了一些值..
然后在第二个用户的表单上显示相同的更改。
怎么做???
我被困了..帮助
I''m developing app. using C# and SQL Server 2005,
What i''m trying to do is "Update User Interface when there is change in database",
suppose, there is datagrid on a form..
two different users on different computers -open the form simultaneously.
one user edits some value..
then the same change displayed on the second user''s form.
how to do this??
I''m stuck.. help
推荐答案
好吧,我之前做过Web应用程序而不是桌面应用程序。我使用JavaScript来做到这一点,即使是AJAX在我的特定情况下并没有多大帮助,也没有多线程实现。
我认为你很难找到,我听说过网络c#中的stream-socket但是没有尝试做,也就是多线程,你的应用程序应该根据你的情况实现。
问候,
Bassem
Well, I did it before as a web application not a desktop application. I used JavaScript to do that, even AJAX didn''t help me much in my specific case, and a multi-threading implementation.
I think it is difficult what you are seeking, I heard about network stream-socket in c# but didn''t try to do, also multi-threading, your application should be implemented according to your case.
Regards,
Bassem
如何自动告诉连接的客户端数据库/表中是否有变化?
How to automatically tell the connected clients that there is change in database/tables?
我自己从未这样做过,但我自己我相信这里有专家....我认为你可以配置MS Sql Server 2005在发生变化时发送通知。
如果有可能你可以能够在.NET应用程序中接收该通知。
如果你能做到这一点,那么你正在寻找的解决方案可能会涉及套接字....但是我我不确定SQL Server可以做什么,所以我可能在这里错了。
我对此的初步想法是:
- 实现一个侦听对MS Sql所做更改的Socket服务器
- 服务器也监听Socket连接(来自客户端) )$ / b $ b当套接字服务器检测到对MS SQL Server所做的更改时,它会向连接到它的所有套接字连接发送通知。
- 实现使用套接字的.NET客户端应用程序连接到套接字服务器....他们收到通知并做任何事情发生时你需要做的事情
I''ve never done this myself but I''m sure an expert here has....I think you can configure MS Sql Server 2005 to send a notification whenever changes are made.
If it''s possible you may be able receive that notification in a .NET application.
If you can do that then the solution you''re looking for is probably going to involve Sockets....but I''m not sure what the SQL Server can do so I might be wrong here.
My initial thoughts on this are:
- Implement a Socket Server that listens for changes made to the MS Sql
- Server also listens for Socket connections (from clients)
When the Socket Server detects a change made to the MS SQL Server, it sends a notifications to all Socket Connections connected to it.- Implement .NET client applications that use Sockets to connect to the Socket Server....they receive the notification and do whatever you need to do when stuff happens
这篇关于数据库发生更改时更新用户界面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文