SQL连接字符串无法连接SQL实例 [英] SQL Connection String failing to connect SQL Instance

查看:119
本文介绍了SQL连接字符串无法连接SQL实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试调试应用程序,但是当我运行它时,出现以下错误消息:

I am attempting to debug an application, but when I run it I get the following error message:

建立与SQL Server的连接时发生与网络相关或特定于实例的错误.服务器未找到或无法访问.验证实例名称正确,并且已将SQL Server配置为允许远程连接.(提供者:SQL网络接口,错误:26-指定服务器/实例时出错)

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: 26 - Error Locating Server/Instance Specified)

我已经打开了1433端口,并仔细检查了它的开放性,并且可以从当前位置访问该端口.我还启用了TCP/IP远程连接,并可以使用SQL Server Studio Manager进行远程连接.

I've opened up the 1433 port and double-checked it's open and reachable from my current location. I've also enabled TCP/IP remote connections and can connect remotely using SQL Server Studio Manager.

我正在使用的连接字符串是:

The connection string I'm using is:

Data Source=xx.xx.xxx.xx, 1433;Network Library=DBMSSOCN;Initial Catalog=KnightOwl-Demo;Persist Security Info=True;User ID=KnightOwlGentleshaw; Password=xxxxxx

我确定90%的连接字符串有问题,但是我不确定是什么?

I'm 90%sure there's something wrong with the connection string but I'm not sure what?

推荐答案

如果不确定连接字符串,请使用udl文件进行测试:

If you are not sure about the Connection string, use a udl file for testing:

  1. 创建一个新的文本文件.
  2. 将扩展名更改为 .udl (例如,将 1.txt 更改为 1.udl )
  3. 转到"连接"标签
  4. 插入您的凭据(服务器名\实例,用户名和密码/Windows安全性等)
  5. 选中允许保存密码复选框
  6. 单击测试连接并获得成功消息.
  7. 单击确定"(这将关闭表格)
  8. 在文本编辑器中打开 1.udl 文件-该文件将包含用于成功连接的连接字符串
  1. Create a new text file.
  2. Change the extension to .udl (e.g. 1.txt to 1.udl)
  3. Go to the Connection tab
  4. Insert your credentials (Servername\instance , user name + password / Windows security etc)
  5. Check the Allow saving password check box
  6. Click on Test Connection and get a success message.
  7. Click on OK (this will close the form)
  8. Open the 1.udl file in a text editor - It will contain the connection string that was used for the successful connection

现在您可以比较连接字符串/使用您现在可以使用的连接字符串...

Now you can compare the connection strings / use the one you now that works...

祝你好运!

这篇关于SQL连接字符串无法连接SQL实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆