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");
你能證明非工作代碼? – 2010-09-18 12:34:42