Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/322.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# 使用C连接到远程MySQL时出现问题_C#_Mysql_Visual Studio_Connection String - Fatal编程技术网

C# 使用C连接到远程MySQL时出现问题

C# 使用C连接到远程MySQL时出现问题,c#,mysql,visual-studio,connection-string,C#,Mysql,Visual Studio,Connection String,我使用的是VisualStudio2010,当我将DataGridView与我的远程mysql db绑定时,它可以正常工作。 但是,当我从向导中获取连接字符串并尝试将其与代码一起使用时,我得到:provider:Named Pipes provider,错误:40-无法打开到SQL Server的连接 这是我尝试的连接字符串我尝试了许多变体: Server=myserver.org;数据库=我的数据库;Uid=myuser;Pwd=mypwd 有什么想法吗? 谢谢 代码如下: 字符串连接字符串=

我使用的是VisualStudio2010,当我将DataGridView与我的远程mysql db绑定时,它可以正常工作。 但是,当我从向导中获取连接字符串并尝试将其与代码一起使用时,我得到:provider:Named Pipes provider,错误:40-无法打开到SQL Server的连接

这是我尝试的连接字符串我尝试了许多变体: Server=myserver.org;数据库=我的数据库;Uid=myuser;Pwd=mypwd

有什么想法吗? 谢谢

代码如下: 字符串连接字符串=Server=sql.Server.org;数据库=我的数据库;Uid=我的用户;Pwd=mypwd

SqlConnection myConnection = new SqlConnection(connectionString); SqlDataAdapter mySqlDataAdapter = new SqlDataAdapter("Select * from Table", myConnection); DataSet myDataSet = new DataSet(); DataRow myDataRow; // Create command builder. This line automatically generates the update commands for you, so you don't // have to provide or create your own. SqlCommandBuilder mySqlCommandBuilder = new SqlCommandBuilder(mySqlDataAdapter); // Set the MissingSchemaAction property to AddWithKey because Fill will not cause primary // key & unique key information to be retrieved unless AddWithKey is specified. mySqlDataAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey; mySqlDataAdapter.Fill(myDataSet, "Table"); 已解决:显然SqlConnection不是为MySQL创建的


改为使用:MySqlConnection

能否显示非工作代码?
           string connectionString = "server=localhost;uid=root;pwd=***********;database=terra_incognita_online";
           MySqlConnection sqlConnection = new MySqlConnection();
           sqlConnection.ConnectionString = connectionString;
           sqlConnection.Open();
           Console.WriteLine("open");
           sqlConnection.Close();
           Console.WriteLine("close");