c# - 无法从 C# 表单应用程序访问 MYSQL 服务器 - 连接字符串错误

标签 c# mysql

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/

相关文章:

php - 在mysqli中获取多行

c# - 如何在 C# 中向 SQLDataSource 添加更新参数

c# - T 是 type1 或 type2 的通用方法

php - mysql php 列

php - 如何使用 PDO+PHP 使用第一个表中的主键从通过多对多关系连接的表中检索数据?

MySQL 不查询主键

c# - 如何在单个 mvc3 View 中添加两个表?

c# - 表格中的光标点

c# - C# 中的 uniqueidentifier 等效数据类型

java - MYSQL Workbench 未填充 Spring Boot JPA 实体的表数据