如何通过网络与2个桌面应用程序共享单个数据库,c#中的应用程序和mssql中的数据库
嘿伙计们,我正在用 C# 做两个桌面应用程序。每一个都适用于 2 个不同的人,但问题是用户/客户端都希望在他们的应用程序之间共享数据。例如:第一个人在他家安装该软件,第二人在他家安装另一个软件。现在,两个用户都想共享一个数据库。
我应该怎么做?我的意思是,如果它是一个 Web 应用程序,那么我可以将数据库托管在服务器上。但是,由于它是桌面应用程序,我很困惑该怎么做?
hey guys, I'm doing two desktop applications in c#. Each one is for 2 different people but the problem is both user/client want to share data between their App. For example: The first person installs the software at his home and the second person installs the other software at his home. Now, both users want to share a single DB.
how i should go for this? I mean, if it was a web application then i could host the database on a server. However, since it is a desktop application, I'm confused how to do it ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您很可能想做完全相同的事情。您需要将数据库托管在两个应用程序都可以访问的服务器上。您可以自行托管,也可以使用可以提供托管 SQL 服务器的现有服务提供商。取决于你要花多少钱,以及你的 SQL 管理能力。
桌面应用程序和 Web 应用程序都使用相同的访问 SQL 数据库的方法,您只需通过连接字符串将其连接起来。但是,您必须小心如何管理和传递连接字符串中的凭据,因为您需要通过 Internet 进行远程身份验证。
You will most likely want to do exactly the same thing. You will need to host the database on a server which both applications will be able to access. Either host it yourself, or use an existing service provider who can provide hosted SQL server. Depends on how much money you have to spend on it, and how capable you are with SQL administration.
A desktop application and web application both utilise the same method of accessing a SQL database, you just hook it up through the connection string. You will have to be careful about how you manage and pass the credentials in the connection string, however, as you will need to authenticate remotely over the Internet.
我相信您将需要设置一个托管数据库(可通过网络访问),除非您想开始在两个应用程序之间设置 P2P 连接,这两个应用程序要么知道用户的家庭 IP 地址,要么设置一个中间人来设置建立连接。
I believe you're going to need to set up a hosted database (web accessible), unless you want to start setting up P2P connections between the two applications which would either knowing the users home IP address or setting up a middle-man to set up the connection.