C#使用/连接到Webhost(One.com)中的MySQL数据库 [英] C# Use/connect to MySQL database in webhost (One.com)

查看:108
本文介绍了C#使用/连接到Webhost(One.com)中的MySQL数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用C#winforms应用程序连接到我的one.com虚拟主机.支持人员说不允许外部连接,那我该如何在Webhost上读取数据库表?有人告诉我,如果我在网站上使用PHP,那么它将起作用,而且确实可以.但是我应该如何从程序中访问该代码并使其返回一些值?

I want to connect to my one.com webhost, by using my C# winforms application. The support said extern connections is NOT allowed, then how am I gonna read the database table on my webhost? I was told that if I used PHP on the website, then it would work, and it does. But how should i access that code from my program and make it return some values?

任何帮助将不胜感激.预先感谢.

Any help will be appreciated. thanks in advance.

PS.如果我不清楚某个地方,或者如果您需要更多信息,那么只需说明需要什么.

PS. If i'm unclear somewhere, or if you need more information then just explain what's needed.

推荐答案

您的网络主机可能已经限制了对数据库的访问,因此只有特定的主机可以连接到该主机,即托管基于PHP的网站的主机.这是一种常见的做法.

Your webhost has probably restricted the access to your database so that only a specific host can connect to it, namely the one hosting your PHP based website. This is a common practice.

在这种情况下,您将无法从任何其他主机进行连接-因此,您的C#winforms应用将无法连接任何一个.

If this is the case, you cannot connect from any other host - and thus, your C# winforms app won't be able to connect either.

因此,从C#应用程序到数据库的直接连接不是一个选择,但是您可以使用PHP实现一个REST接口,该接口将所需的数据提供给外界.然后,客户端可以使用您的C#应用​​程序进行访问.这是我能想到的唯一解决方案.

So a direct connection from your C# app to your database isn't an option, but you might implement a REST interface with PHP that serves the data you need to the outside world. This could then be accessed by the clients using your C# app. This is the only solution I can think of.

这篇关于C#使用/连接到Webhost(One.com)中的MySQL数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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