如何在C#中使用Access数据库触发触发器 [英] how to fire trigger with access database in C#

查看:467
本文介绍了如何在C#中使用Access数据库触发触发器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,有两种不同的应用程序形式使用相同的数据库和相同的MS访问表.一旦从一种应用程序形式插入该表中的数据,我就希望触发选择查询以在第二个应用程序中显示该新记录. br/>
它是一个客户端服务器应用程序...因此,一旦服务器上的用户输入新记录,客户端必须知道更新的客户端...


如何做到这一点..在C#中可以做到这一点吗?.
谢谢..

In my application there are two different application form uses same database and same table of MS access.As soon as data inserted into that table from one application form i want fire select query to display that new record in second application from.

Its a client server application...so once the user on server enter the new record client have to know updated ones...


how to do this..is it any way in C# for that..
thanks..

推荐答案

在使用Microsoft Access时,您只能做些事情.应用程序可以对更改做出反应的方式有两种:一种是通过推送机制,底层服务器将更改推送到连接的应用程序.另一种机制是通过拉机制,其中应用程序拉出他们感兴趣的数据.

现在,您不能在此处使用推送机制,因为Access并非设计为在具有入站连接知识的情况下作为基于服务器的应用程序运行.这意味着您只能拉取数据-这表示您需要监视数据库以更改客户端感兴趣的记录.

我的建议是在这里采取两种做法.第一个分支将是准备好更新的字段/表(带有时间戳记imfo)以标识已更改的内容.第二个分支是让您的应用程序检查更改的记录(在后台线程上),并相应地进行更新.

不幸的是,这没有简单的方法-您将不得不编写很多代码.
As you are using Microsoft Access, you are limited in the scope of what you can do. There are two ways that an application can react to changes - one is through a push mechanism, whereby the underlying server pushes out changes to connected applications. The other mechanism is through a pull mechanism, where the applications pull the data they are interested in.

Now, you can''t use a push mechanism here because Access is not designed to run as a server based application with knowledge of inbound connections. This means that you are limited to pulling the data - which indicates that you need to monitor the database for changes to records the client is interested in.

My suggestion would be to take a two pronged approach here. The first prong would be to have an updated field/table (with timestamp imfo) in place to identify what has changed. The second prong is to have your application check for changed records (on a background thread), and update itself accordingly.

Unfortunately, there''s no easy way round this - there''s a lot of code you''re going to have to write.


如果表单处于同一过程中,您可以将信号量用作进程间通信功能.

目前,我没有时间编写代码,但是如果您向MSDN咨询这些资源的使用情况,则应该可以弄清楚.
If the forms are in in the same process, you could use a Semaphore as an interprocess communication feature.

At this time I do not have the time to whip up code, but if you consult MSDN on the usage of those resources you should be able to figure it out.


是否有必要使用2个应用程序.您不能在单个应用程序中使用2种形式来加速和简便.
Is it necessary to use 2 applications. can''t you use 2 forms in single application for this purpose to speed up and easiness.


这篇关于如何在C#中使用Access数据库触发触发器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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