简体   繁体   English

桌面应用程序的数据库托管

[英]Database hosting for desktop application

I am seeking a way to access database (sql server or mysql) via application.我正在寻找一种通过应用程序访问数据库(sql server 或 mysql)的方法。 The tricky part is that the application (C# based) will be present on several machines and they all have to access same data, which means I have to think a way to host the database.棘手的部分是应用程序(基于 C#)将存在于几台机器上,它们都必须访问相同的数据,这意味着我必须想办法托管数据库。 And this is where I need help...all I find in the internet is web site databases which are not accessible in desktop apps or payed hosting... hosting the database from my machine is also an option although I'm not sure if it is possible at all.这就是我需要帮助的地方......我在互联网上找到的所有内容都是 web 站点数据库,这些站点数据库在桌面应用程序或付费托管中无法访问......虽然我不确定是否可以从我的机器托管数据库也是一种选择这是可能的。 So all sorts of options are welcome.因此,欢迎各种选择。

Data access is an application independant issue. 数据访问是一个独立于应用程序的问题。

It shouldn't matter if your application is desktop-based or web-based, as both (web and desktop) would use C#, they use the same code to access the database. 如果您的应用程序是基于桌面的或基于Web的,则无关紧要,因为(Web和桌面)都使用C#,它们使用相同的代码来访问数据库。

It also wouldn't matter if it was on the same machine or the other end of the world, it would (probably) go over TCP/IP, to connect. 如果它位于同一台机器或世界的另一端也无关紧要,它可能(可能)通过TCP / IP连接。

What do you do, totally depends on needs/budget. 你做什么,完全取决于需求/预算。

You're fine with SQL server. 你对SQL服务器很好。

The only requirement for code accessing a database is that it can actually access it (ie establish a connection to the DB). 代码访问数据库的唯一要求是它实际上可以访问它(即建立与数据库的连接)。

I've done a project recently whereby all computers (7 in total) were already connected in a small office network. 我最近做了一个项目,所有计算机(总共7台)已经连接在一个小型办公网络中。 One of these computers was chosen as the host and acted as the DB server, whilst the code on all other 'client' computers contained a connection string that pointed to this one host; 其中一台计算机被选为主机并充当数据库服务器,而所有其他“客户机”计算机上的代码包含一个指向这一台主机的连接字符串; I get the impression this is what you're after. 我得到的印象就是你所追求的。

With that in mind, develop your application as though the DB were local (I would actually recommend you do code against a local SQL server instance during dev) and worry about the data access later when it comes to amending the connection string (as long as you're sure you will have the facilities in place to allow this connection). 考虑到这一点,开发您的应用程序就好像数据库是本地的(我实际上建议您在开发期间对本地SQL服务器实例执行代码)并且在修改连接字符串时担心以后的数据访问(只要您确定您将拥有适当的设施以允许此连接)。

I would recommend you factor in some additional time for installation of configuration of your SQL server if you're new to this. 如果您是新手,我建议您考虑安装SQL服务器配置的额外时间。 It won't be a massive task, but don't underestimate it if you're working off time estimates. 这不是一项艰巨的任务,但如果你正在计算时间估计,不要低估它。

Website Database accessed by Desktop Application! 桌面应用访问的网站数据库! I wrote a set of simple PHP pages that provide query access from my MySQL database on a remote web server to my desktop windows forms application. 我编写了一组简单的PHP页面,提供从远程Web服务器上的MySQL数据库到桌面Windows窗体应用程序的查询访问。 These pages use small PHP scripts to provide insert, select, update, and delete capabilities. 这些页面使用小型PHP脚本来提供插入,选择,更新和删除功能。 The C# desktop app posts sql statements via System.Net.Http.HttpClient to these web pages. C#桌面应用程序通过System.Net.Http.HttpClient将sql语句发布到这些网页。 The pages perform the sql and return information to the System.Net.Http.HttpResponseMessage object. 这些页面执行sql并将信息返回给System.Net.Http.HttpResponseMessage对象。

In the case of select statements, the php has a small script that converts the database rows to XML to return to the response object. 在select语句的情况下,php有一个小脚本,它将数据库行转换为XML以返回到响应对象。 You can then use a System.Data.DataSet to import the XML string by the ReadXml method. 然后,您可以使用System.Data.DataSet通过ReadXml方法导入XML字符串。

My website has a fixed IP and an SSL certificate. 我的网站有固定的IP和SSL证书。 The scripts demand https://... and reject any request made with just http://... 脚本需要https:// ...并拒绝任何仅使用http://发出的请求...

Because of the round trip data access time, the application is a little slower than if the database was on a local server. 由于往返数据访问时间,应用程序比数据库在本地服务器上慢一点。 You can secure access by requiring certain credentials in your post requests. 您可以通过在帖子请求中要求某些凭据来保护访问权限。

A benefit is that independent users can access the data without having to be on a particular network. 好处是独立用户无需在特定网络上即可访问数据。

For you as the developer, it may be easier to develop windows desktop apps with complex UI operations than trying it on a website. 对于您作为开发人员而言,开发具有复杂UI操作的Windows桌面应用程序可能比在网站上尝试它更容易。

I have same issue, a desktop app (vb) with a mysql database hosted in my website.我有同样的问题,一个桌面应用程序(vb),在我的网站上托管了一个 mysql 数据库。 The idea is: have an online database that i can use it anywhere, for example: i can develop an app mobile to read or validate some infos... Any ideas please?这个想法是:拥有一个我可以在任何地方使用它的在线数据库,例如:我可以开发一个移动应用程序来阅读或验证一些信息......请问有什么想法吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM