.NET中两个应用程序之间的数据库共享 [英] Database sharing between two applications in .NET

查看:72
本文介绍了.NET中两个应用程序之间的数据库共享的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用表单应用程序和使用.net(SQL服务器数据库)的Web应用程序,我想在表单应用程序和Web应用程序之间共享数据库。即任何一个应用程序在数据库中所做的更改应反映在其他应用程序中。我有什么选择来实现它?



我对Web服务有点了解(只是概念)。如果同样可以用于此目的(数据库共享),请告诉我,如果是,如何?否则欢迎任何其他解决方案。谢谢。 :)

解决方案

请参阅:



* [ MSDN ] 如何:创建和运行CLR SQL Server触发器 [ ^ ]

* [ c-sharpcorner ] 创建,您先CLR触发式-SQL服务器2008年使用-C-夏普/ [ ^ ]



另请参阅 CP 文章:触发器 - SQL Server [ ^ ]



干杯,

Canny


我不是确定你的意思我希望在表单应用程序之间共享数据库(..)从任何一个应用程序在数据库中所做的更改应该反映在其他...



看看 SQLDependecy类 [ ^ ]。

以下是一个示例实现:使用SqlDependency进行数据更改事件 [ ^ ]



如需了解更多信息,请参阅:

使用SqlDependency检测更改 [ ^ ]

在Windows应用程序中使用SqlDependency [ ^ ]

ASP.NET应用程序中的SQLDependency [ ^ ]







如果您不知道如何设置SQL Server实例来收听网络连接,请阅读:

配置要侦听的服务器特定TCP端口(SQL Server配置管理器) [ ^ ]

配置服务器以备用的方式收听管道(SQL Server配置管理器) [ ^ ]

注意:有时需要配置防火墙

配置Windows防火墙以允许SQL Server访问 [ ^ ]



[/ EDIT ]

I am using a form application and a web application using .net(SQL server database) and i want to share the database between form application and web application. i.e. changes made in the database from any one application should be reflected in other. What are my options to implement the same?

I have a little idea about Web service(just the concept). Also let me know if the same can be used for this purpose(database sharing)and if so, how? Any other solution is otherwise welcomed. Thanks. :)

解决方案

See:

* [MSDN] How to: Create and Run a CLR SQL Server Trigger[^]
* [c-sharpcorner] create-your-first-clr-trigger-in-sql-server-2008-using-C-Sharp/[^]

See also CP article: Triggers -- SQL Server[^]

Cheers,
Canny


I'm not sure what you mean "i want to share the database between form application (..) changes made in the database from any one application should be reflected in other"...

Have a look at SQLDependecy class[^].
Here is an sample implementation: Using SqlDependency for data change events[^]

For further information, please see:
Detecting Changes with SqlDependency[^]
Using SqlDependency in a Windows Application[^]
SqlDependency in an ASP.NET Application[^]

[EDIT]

If you don't know how to set up instance of SQL Server to listen network connections, please read this:
Configure a Server to Listen on a Specific TCP Port (SQL Server Configuration Manager)[^]
Configure a Server to Listen on an Alternate Pipe (SQL Server Configuration Manager)[^]
Note: sometimes it's necessary to configure firewall
Configure the Windows Firewall to Allow SQL Server Access[^]

[/EDIT]


这篇关于.NET中两个应用程序之间的数据库共享的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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