vb.net 提供程序:SQL 网络接口,错误:25 - 连接字符串无效

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16218553/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 13:23:41  来源:igfitidea点击:

provider: SQL Network Interfaces, error: 25 - Connection string is not valid

vb.netconnection-string

提问by Nita

I developed this application on my local computer using VS2012 and SQL 2008R2. I am trying to move it onto production server. It is a virtual server with 2012 SQL Server. I checked all the properties for remote connection and everything is enabled. The application opens with the login screen and once I enter the username and password (this was created on my computer using WSAT. Now I get this error: 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: SQL Network Interfaces, error: 25 - Connection string is not valid) This is what I have in web.config:

我使用 VS2012 和 SQL 2008R2 在我的本地计算机上开发了这个应用程序。我正在尝试将它移到生产服务器上。它是一个带有 2012 SQL Server 的虚拟服务器。我检查了远程连接的所有属性,一切都已启用。当我输入用户名和密码(这是使用 WSAT 在我的计算机上创建的。现在我收到此错误:与 SQL Server 建立连接时发生与网络相关或特定于实例的错误。服务器未找到或无法访问。验证实例名称是否正确,并且 SQL Server 配置为允许远程连接。(提供程序:SQL 网络接口,错误:25 - 连接字符串无效)这就是我所拥有的网络配置:

<connectionStrings>
    <remove name="LocalSqlServer" />
<add connectionString="Server=\events;Database=Digital Signage;Integrated Security=true" name="DSConnectionString" />
    <add connectionString="data source=\events;Integrated Security=SSPI;AttachDBFilename=c:\DS\aspnetdb.mdf;User Instance=true" name="LocalSqlServer" providerName="System.Data.SqlClient" />

回答by nkvu

Not entirely sure, but some points which may help you troubleshoot:

不完全确定,但可以帮助您排除故障的一些要点:

  • You can use a resource like thisto help you generate the appropriate connection string
  • I am not sure that Server=\\eventssounds entirely right - you should perhaps replace this with the actual SQL instance name here when deploying remotely (either <machine name>or <machine name>\<instance name>for a named instance)
  • You probably don't need to explicitly state the port which SQL Server is listening on (if it's still the default 1433), but something to keep in mind
  • Do you have anywhere that you explicitly reference the connection string LocalSqlServerin your code? If so, have you changed that to reference the connection string DSConnectionStringbefore building and deploying? (NB.It may be better to just keep the connection string entry but change the value of the connection string to what you need for the SQL 2012 instance, rather than creating a new connection string entry but I'm not sure about your specific use case)
  • 您可以使用的资源像这样帮你生成适当的连接字符串
  • 我不确定这Server=\\events听起来是否完全正确 - 在远程部署(<machine name><machine name>\<instance name>为命名实例)时,您或许应该将其替换为此处的实际 SQL 实例名称
  • 您可能不需要明确说明 SQL Server 正在侦听的端口(如果它仍然是默认的 1433),但要记住一些事情
  • 你有没有LocalSqlServer在代码中明确引用连接字符串的地方?如果是这样,您是否DSConnectionString在构建和部署之前将其更改为引用连接字符串?(注意。最好只保留连接字符串条目,但将连接字符串的值更改为 SQL 2012 实例所需的值,而不是创建新的连接字符串条目,但我不确定您的具体用途案件)