Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/310.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Can';t从c#表单应用程序访问MYSQL服务器-连接字符串中出错_C#_Mysql - Fatal编程技术网

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的例子