【发布时间】:2020-03-13 08:36:54
【问题描述】:
我正在尝试从 JavaFX 迁移一些代码以将 C# 用于 Windows 窗体。在 Java 中,我使用的是 JDBC,并且可以通过编程很好地连接。不,我正在尝试使用 C# 我收到此错误:
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。我尝试了很多不同的组合,但无法让连接字符串正常工作。
String connectionString = "server=[Server URL];database=[Database Name];persist security info=true;user id=[Username];pwd=[Password]";
【问题讨论】:
-
System.Data.SqlClient仅适用于 Microsoft SQL Server。您需要使用System.Data.Odbc或dev.mysql.com/downloads/connector/net 的MySQL 连接器
标签: java c# mysql winforms mariadb