0
myConnection = new SqlConnection("user id=champion3_test;" +
                                       "password=test;server=10.168.1.58;" +
                                       "Trusted_Connection=true;" +
                                       "database=champion3_sabdb; " +
                                       "connection timeout=30");

このコードはエラーを出します:

Thrown: "A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)" (System.Data.SqlClient.SqlException) Exception Message = "A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)", Exception Type = "System.Data.SqlClient.SqlException", Exception WinRT Data = ""    

サーバーの設定のデバッグに役立つ可能性のあるスクリーンショットを次に示します。http: //imgur.com/a/PeRby

「champion3_test」が有効なユーザーIDであることがわかっています。「test」はchampion3_testの有効なパスワードです。データベース名は「champion3_sabdb」です。

4

2 に答える 2

4

SQLサーバーはMySQLではありません。MySQLを使用している場合は、MySQL .NETコネクタをダウンロードし、それらの接続クラスMySqlConnectionを使用します。

MySQLコネクタの使用方法については、ここから開始できます。

于 2013-03-13T15:06:24.683 に答える
0

MySql Connectorfor.Netはここからダウンロードできます。

ドライバをインストールしたら、MySqlコネクタクラスを使用して接続できます。

 string connStr = "server=localhost;user=root;database=world;port=3306;password=******;";
 MySqlConnection conn = new MySqlConnection(connStr);
于 2013-03-13T15:09:59.703 に答える