2010-09-18 110 views
0

我使用的是Visual Studio 2010,当我使用远程mysql数据库绑定DataGridView时,它正常工作
但是当我从向导带连接字符串,并尝试以代码中使用它,我得到:“provider:命名管道提供程序,error:40 - 无法打开到SQL Server的连接”用C连接远程MySQL的问题#

这是连接字符串我尝试(我尝试了很多变种):
“Server = myserver.org; Database = my_db; Uid = myuser; Pwd = mypwd;”

有什么想法吗?
感谢

这里是代码:
字符串的connectionString = “服务器= sql.server.org;数据库= MY_DB; UID = my_user; 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"); 
+0

你能证明非工作代码? – 2010-09-18 12:34:42

回答

0

解决:显然的SqlConnection为MySQL

不言

使用:的MySqlConnection代替