Sql server 为什么我会得到;无法连接到服务器-网络相关或实例特定错误“;?
尝试连接到SQL Server时出现以下错误: 无法连接到108.163.224.173 与网络有关或 建立到的连接时发生特定于实例的错误 SQL Server 找不到服务器或无法访问服务器。验证 实例名称正确且SQL Server配置为 允许远程连接 (提供程序:命名管道提供程序,错误:40)- 无法打开与SQL Server的连接(Microsoft SQL Server, 错误:1326) 在VisualStudio2010中尝试将数据库配置为gridview时引发此错误。我不知道如何调试这个错误Sql server 为什么我会得到;无法连接到服务器-网络相关或实例特定错误“;?,sql-server,visual-studio,database-connection,azure-virtual-machine,Sql Server,Visual Studio,Database Connection,Azure Virtual Machine,尝试连接到SQL Server时出现以下错误: 无法连接到108.163.224.173 与网络有关或 建立到的连接时发生特定于实例的错误 SQL Server 找不到服务器或无法访问服务器。验证 实例名称正确且SQL Server配置为 允许远程连接 (提供程序:命名管道提供程序,错误:40)- 无法打开与SQL Server的连接(Microsoft SQL Server, 错误:1326) 在VisualStudio2010中尝试将数据库配置为gridview时引发此错误。我不知道如何调试
如何调试此错误?除了错误消息中提到的步骤之外,我还应该采取哪些步骤来确定这里到底发生了什么?我发现以下技术非常有用:
- 开始>所有程序>SQL Server 2005>配置工具>SQL Server外围区域配置
- 单击服务和连接的表面积配置
- 选择有问题的实例>数据库引擎>远程连接
- 启用本地和远程连接
- 重新启动实例
- 开始>运行>防火墙.cpl
- 单击例外选项卡
- 添加sqlservr.exe(通常位于
,检查安装中的实际文件夹路径)和端口(默认值为C:\Program Files(x86)\Microsoft SQL Server\MSSQL.x\MSSQL\Bin
)1433
- 同时检查您的连接字符串
- 发件人:
- 转到所有程序>Microsoft SQL Server 2008>配置工具>SQL Server配置管理器>SQL Server服务
- 检查以确保SQL Server服务状态正在运行
sqlcmd-L
以确定您的服务器是否包含在网络列表中
- 转到所有程序>>Microsoft SQL Server 2008>>配置工具>>SQL Server配置管理器>>选择TCP/IP
- 右键单击TCP/IP>>单击启用
我发现以下技术很有用:
- 开始>所有程序>SQL Server 2005>配置工具>SQL Server外围区域配置
- 单击服务和连接的表面积配置
- 选择有问题的实例>数据库引擎>远程连接
- 启用本地和远程连接
- 重新启动实例
- 开始>运行>防火墙.cpl
- 单击例外选项卡
- 添加sqlservr.exe(通常位于
,检查安装中的实际文件夹路径)和端口(默认值为C:\Program Files(x86)\Microsoft SQL Server\MSSQL.x\MSSQL\Bin
)1433
- 同时检查您的连接字符串
- 发件人:
- 转到所有程序>Microsoft SQL Server 2008>配置工具>SQL Server配置管理器>SQL Server服务
- 检查以确保SQL Server服务状态正在运行
sqlcmd-L
以确定您的服务器是否包含在网络列表中
- 转到所有程序>>Microsoft SQL Server 2008>>配置工具>>SQL Server配置管理器>>选择TCP/IP
- 右键单击TCP/IP>>单击启用
我找到了解决方案: 打开“SQL Server配置管理器” 现在单击“SQL Server网络配置”并单击“名称协议” 右键单击“TCP/IP”(确保它已启用)单击属性 现在选择“IP地址”选项卡并转到最后一项“IP全部” 输入“TCP端口”1433 现在重新启动“SQL Se
PM> update-database -Verbose
Using StartUp project 'Droid'. <-- DROID
Using NuGet project 'Web'. <-- WEB
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
<!-- BAD TARGET DATABASE -->
Target database is: 'DefaultConnection' (DataSource: .\SQLEXPRESS, Provider: System.Data.SqlClient, Origin: Convention).
System.Data.SqlClient.SqlException (0x80131904): 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)
[REMOVED TEXT]
ClientConnectionId:00000000-0000-0000-0000-000000000000
Error Number:-1,State:0,Class:20
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)
Troubleshooting Steps
Resolution Steps:
using (var connect = Connections.mySqlConnection)
{
const string query = "SELECT Name, Birthdate, Narrative FROM Friends";
using (var command = new SqlCommand(query, connect))
{
connect.Open();
using (var dr = command.ExecuteReader())
{
while (dr.Read())
{
// blah
}
}
}
}
Name Birthdate Narrative
==== ========= ==============
Fred 21-Oct-79 <!--HTML Comment -->Once upon a time...
Name Birthdate Narrative
==== ========= ==============
Fred 21-Oct-79 <!--HTML Comment -->Once upon a time...
UPDATE Friends SET Narrative = '<!--HTML Comment -->Once upon a time...' WHERE Narrative LIKE '<%'
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="SqlConnectionString" connectionString="Data Source=.; Initial Catalog=TestDB; Trusted_Connection=True;" providerName="System.Data.SqlClient" />
</connectionStrings>