Can';t从c#表单应用程序访问MYSQL服务器-连接字符串中出错
此代码给出了错误信息:Can';t从c#表单应用程序访问MYSQL服务器-连接字符串中出错,c#,mysql,C#,Mysql,此代码给出了错误信息: myConnection = new SqlConnection("user id=champion3_test;" + "password=test;server=10.168.1.58;" + "Trusted_Connection=true;" +
myConnection = new SqlConnection("user id=champion3_test;" +
"password=test;server=10.168.1.58;" +
"Trusted_Connection=true;" +
"database=champion3_sabdb; " +
"connection timeout=30");
以下是一些可能有助于调试我的服务器设置的屏幕截图:
我知道“champion3_测试”是一个有效的用户id
“test”是champion3_测试的有效密码
数据库名为“champion3_sabdb”SQL server不是MySQL。如果您使用的是MySQL,请下载MySQL.NET连接器并使用其连接类
要了解如何使用MySQL连接器,您可以开始。SQL server不是MySQL。如果您使用的是MySQL,请下载MySQL.NET连接器并使用其连接类
要了解如何使用MySQL连接器,您可以开始。您可以下载.Net的MySQL连接器 安装驱动程序后,可以使用MySql连接器类进行连接:
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 = ""
您可以下载.Net的MySql连接器 安装驱动程序后,可以使用MySql连接器类进行连接:
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 = ""
对于初学者,不应该像这样创建
SqlConnection
。我强烈建议把它放在一个配置文件中,google
上有很多关于如何在App.config文件中配置/数据库连接字符串的例子对于初学者来说,你不应该像这样创建SqlConnection
。我强烈建议把它放在一个配置文件中,google
上有很多关于如何在App.config文件中配置/Database ConnectionString的例子