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”
最佳答案
SQL 服务器不是 MySQL。如果您使用的是 MySQL,请下载 MySQL .NET 连接器并使用其连接类 MySqlConnection .
要了解如何使用 MySQL 连接器,您可以开始 here .
关于c# - 无法从 C# 表单应用程序访问 MYSQL 服务器 - 连接字符串错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15388956/