如何解决如何创建 connectionString 将 ado.net c# 连接到运行 SQL Server 的虚拟机
我在连接到在虚拟机(virtualBox)上运行的 sql Server 时遇到了一些困难。我在 C# 中使用 ADO.NET 通过连接字符串进行连接,但我没有成功。
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<connectionStrings>
<add name="AP3"
connectionString="Data Source=190.166.2.8,1433;Initial Catalog=AP3;
User Id=sa;Password=PasswOrd;"
providerName="System.Data.sqlClient" />
</connectionStrings>
</configuration>
我不知道我做错了什么...
解决方法
您似乎不允许使用 Sql Server 进行远程连接。请关注此link了解更多详情
,您可以添加 DBMSSOCN 以使用 TCP/IP 而不是命名管道。也许这是一个问题。
试试这个连接字符串。
"Data Source=190.166.2.8,1433;Network Library=DBMSSOCN;Initial Catalog=AP3; User Id=sa;Password=PasswOrd;"
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。