Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/330.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/61.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
C# 连接到C中的外部SQL数据库#_C#_Mysql_Sql_.net - Fatal编程技术网

C# 连接到C中的外部SQL数据库#

C# 连接到C中的外部SQL数据库#,c#,mysql,sql,.net,C#,Mysql,Sql,.net,我在一台外部服务器上安装了SQL server和数据库(为此,我们称域名为“hello.com”),我想通过C#程序连接到这台服务器。到目前为止,我有以下信息(所有服务器/数据库的详细信息都与真实的不同): 这给了我一条错误消息: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was n

我在一台外部服务器上安装了SQL server和数据库(为此,我们称域名为“hello.com”),我想通过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)
我已经检查了所有的连接字符串,并且允许远程访问,因为我现在在同一台计算机上打开了SQLWorkbench查询数据库


有什么想法吗?

您需要
MySQL
驱动程序:

然后可以使用
MySqlConnection
connection类进行连接

MySqlConnection connection = new MySqlConnection(connectionString);

您不能使用
SqlConnection
对象连接到MySQL数据库,您应该在导入其dll后使用
MySqlConnection
,如果数据库是sql server,为什么要将其标记为MySQL?请使用connectionStringIt的MySQL服务器中的名称检查您的sqlInstance。对不起,我没说清楚。你读过这个吗?编辑:不,不清楚,因为a显然是SQL Server连接。SQL Server状态是否正在运行?如果您使用的是MySQL,请阅读本文。您应该安装。@AllFallD0wn-很高兴为您提供帮助:)
MySqlConnection connection = new MySqlConnection(connectionString);