Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/307.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 错误:无法连接到任何指定的MySQL主机_C#_.net_Asp.net_Mysql_Web Services - Fatal编程技术网

C# 错误:无法连接到任何指定的MySQL主机

C# 错误:无法连接到任何指定的MySQL主机,c#,.net,asp.net,mysql,web-services,C#,.net,Asp.net,Mysql,Web Services,当我尝试打开MySQL连接时,出现以下错误: MySql.Data.MySqlClient.MySqlException: Unable to connect to any of the specified MySQL hosts. at MySql.Data.MySqlClient.NativeDriver.Open() at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings) at MySql

当我尝试打开MySQL连接时,出现以下错误:

MySql.Data.MySqlClient.MySqlException: Unable to connect to any of the specified MySQL hosts.
at MySql.Data.MySqlClient.NativeDriver.Open()
at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)
at MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection()
at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()
at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()
at MySql.Data.MySqlClient.MySqlPool.GetConnection()
at MySql.Data.MySqlClient.MySqlConnection.Open()
*编辑:* 连接字符串:

public string strProvider = "Server=00.00.00.00;Database=someDatabase;Uid=someUser;Pwd=somePassword";
我使用的代码:

string getCompany = "Select * From tbl_company";
MySqlConnection objMyCon = new MySqlConnection(strProvider);
objMyCon.Open();
MySqlCommand cmd = new MySqlCommand(getCompany, objMyCon);
DataTable dt = new DataTable();
MySqlDataAdapter da = new MySqlDataAdapter(cmd);
da.Fill(dt);
objMyCon.Close();

有什么问题吗?

我大胆地建议,您尝试连接的sql服务器不存在。检查连接字符串(应用程序设置)或服务器


Mario

正如我在之前的帖子中指出的那样:连接字符串是一个问题:

00.00.00.00

只是一个无效的IP地址,抱歉。使用localhost或计算机名称(如果mysql服务器在您的pc上)


马里奥

为自己粘贴一些代码!您是否能够使用在代码中指定的连接参数从命令行使用客户端连接到mysql?您是否能够通过mysql查询浏览器连接?您的连接线是什么此处00.00.00.00仅供exmaple使用。实际上这是我的服务器IPI,我使用的是MySQL服务器。我可以通过IE使用它,但我不能用在蟾蜍身上。我可以在服务器端做些什么吗?tcp侦听端口(默认值:3306)是否打开并接受连接?谢谢!这是数据库创建方法的问题。创建数据库时,我错过了其中一个设置。