简体   繁体   English

我可以通过Web服务访问远程数据库吗? C#Winforms

[英]Can I access a remote Database through webservice? C# winforms

Lately I asked this question regarding connecting my window app to a remote database (MySQL) hosted by some free hosting site. 最近,我问了一个有关将我的窗口应用程序连接到某个免费托管站点托管的远程数据库(MySQL)的问题。 And I got "No way" answers. 我得到了“没有办法”的答案。

How about using a webservice? 如何使用网络服务? Is it possible now? 现在可以吗?

Ok (and probably assuming .NET 4.0 on you hosting provider) this should be fairly straightforward: 好的(并且可能在您的托管服务提供商上假设.NET 4.0),这应该非常简单:

  1. Yes you can access data via a webservice. 是的,您可以通过Web服务访问数据。
  2. If you want to with a minimum of effort you can use WCF Data Services 如果您不费吹灰之力就可以使用WCF数据服务
  3. Not tried this but... 没有尝试过这个但是...
    1. Create a web application 创建一个Web应用程序
    2. "Build" an entity framework model for your data (see Using MySQL with Entity Framework for linking EF to MySQL) 为数据“构建”一个实体框架模型(请参阅将MySQL与实体框架一起使用以将EF链接到MySQL)
    3. Create the data service (which seems mostly to be a matter of doing an add new item in visual studio) 创建数据服务(这似乎主要是在Visual Studio中添加新项)
    4. Enable access to data service resources - ie change some code to make sure you can see what you need. 启用对数据服务资源的访问-即更改一些代码以确保您可以看到所需的内容。
    5. At this point you should end up with CRUD access to your database via a fairly comprehensive web service... 在这一点上,您应该最终通过相当全面的Web服务对数据库进行CRUD访问。

Biggest challenge there will be building the EF model - you really want a local instance of the MySQL database - schema at least - to develop against. 最大的挑战将是建立EF模型-您确实希望针对MySQL数据库的本地实例(至少是架构)进行开发。

Yes if your webservice is hosted on same server which contains mysql database. 是,如果您的Web服务托管在包含mysql数据库的同一服务器上。 You can locally connect to mysql using webservice (which hosting providers allow for sure) and can server data using the service. 您可以使用webservice在本地连接到mysql(托管服务提供商肯定会允许),并且可以使用该服务来服务器数据。

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

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