[英]C# xamarin android Unable to connect to any of the specified MySQL hosts
I am trying to make a simple app that will connect to a database and get some info. 我正在尝试制作一个简单的应用程序,它将连接到数据库并获取一些信息。 I have implented the plugin that allows xamarin app to connect remote mariaDB/MySQL to components.
我已经实现了允许xamarin app将远程mariaDB / MySQL连接到组件的插件。 I am using the code below.
我正在使用下面的代码。
public void GetAccountCountFromMySQL()
{
try
{
string sql = " SELECT * FROM Kategorier";
MySqlConnection con = new MySqlConnection("Persist Security Info=False; Server=192.210.241.161; Port=3306; Database=xxxxx; Uid=xxxxx; Pwd=xxxxx;");
MySqlCommand cmd = new MySqlCommand(sql, con);
con.Open();
MySqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
Console.WriteLine(reader.GetString("Sko"));
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
I have tried many types of connection strings, also I buileded a simple C# application that connects to the very same database with no problems. 我尝试了很多类型的连接字符串,我也提供了一个简单的C#应用程序,它连接到同一个数据库,没有任何问题。
实际问题是来自MySql的错误“无法解析主机名”讨论后决定不使用此插件,因为它不安全但创建了一个与MySql DB通信的Web服务并从Android应用程序中使用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.