同步应用程序和数据库 [英] Synchronize application and DB

查看:58
本文介绍了同步应用程序和数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.
我在服务器(SQL SERVER 2005)中有一个e数据库,并且在某些计算机中安装了Windows应用程序.当我在表中进行特定更新时,我想通知所有用户该应用程序是否正在其计算机上运行(例如,显示气球工具Tip).
我是编程领域的新手,我想知道是否有可能做到这一点

我不想使用计时器按顺序检查db.

Hi Every one.
I have e database in server (SQL SERVER 2005) and a windows application installed in some machines. when i make a particular update in a table i want to notify all users if the application is running on its machine (For example, to show a balloon tool Tip ).
I''m new in programming field and I want to know if it is possible to do that

i don''t want to use a timer to check sequentially on db.
thanks.

推荐答案

通知通常是通过从客户端轮询或从服务器端发布到客户端来完成的.

如果您不想从客户端轮询,则必须从服务器进行发布.

可以通过在网络上广播的UDP数据包来完成发布.
Notifications are usually done by polling from the client side, or publishing to clients from the server side.

If you don''t want to poll from the client then you will have to to publishing from the server.

Publishing can be done by a UDP packet broadcast on the network.


您可以使用trriger和2个表进行此操作.



You can do this with a trriger and 2 tables.



CREATE TABLE Event(id INT INDENTITY(0,1), EventTxt VARCHAR(8000))
CREATE TABLE  Viewed (IdUser INT, IdEvent INT, Viewed BIT DEFAULT (0) )
CREATE TRIGGER triger_name
ON   your_table FOR UPDATE AS
 IF
 (
     (UPDATE(your_field))or
 )
 BEGIN
 INSERT INTO Event (EventTxt) VALUES ('Filed was update')
 INSERT INTO
 END



完成此操作后,您将使用手表组件进行查看.
希望新事件在此过程中出现在表中



After you do this you will use a watch component to see.
Want new events are in table with this procedure

PROCEDURE CREATE new_events
@UserId
AS
SELECT e.Id,e.EventTxt FROM 
Event e join Viewed w on e.Id=w.IdEvent WHERE Viewed=0



现在,当应用显示带有事件的消息时,您将
更新已查看SET已查看= 1,其中IdEvent =事件ID和IdUser =已记录的用户



Now when app show message with event you will
UPDATE Viewed SET Viewed=1 WHERE IdEvent= event id AND IdUser= loged user


这篇关于同步应用程序和数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆