本地数据库错误.建立与SQL Server的连接时发生与网络相关或特定于实例的错误 [英] Local db error. A network-related or instance-specific error occurred while establishing a connection to SQL Server

查看:122
本文介绍了本地数据库错误.建立与SQL Server的连接时发生与网络相关或特定于实例的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个运行带有本地数据库的Visual Studio 2015的网站,一切正常.但是生产服务器无法正常工作.

I have web site running Visual Studio 2015 with local db,everything works great. But production server is not working.

连接字符串为

"Data Source = (LocalDB)\MSSQLLocalDB; AttachDbFilename =|DataDirectory|\SeedDb.mdf; Integrated Security=True;MultipleActiveResultSets=True;". 

我尝试了连接字符串

"Data Source = (LocalDB)\V11.00; AttachDbFilename =|DataDirectory|\SeedDb.mdf; Integrated Security=True;MultipleActiveResultSets=True;".

完全错误是:

"/"应用程序中的服务器错误.

Server Error in '/' Application.

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

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: 50 - Local Database Runtime error occurred. The specified LocalDB instance does not exist. )

描述:在执行当前Web请求期间发生未处理的异常.请查看堆栈跟踪,以获取有关错误及其在代码中起源的更多信息.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

异常详细信息:System.Data.SqlClient.SqlException:建立与SQL Server的连接时发生与网络相关或特定于实例的错误.服务器未找到或无法访问.验证实例名称正确,并且已将SQL Server配置为允许远程连接.(提供者:SQL网络接口,错误:50-发生本地数据库运行时错误.指定的LocalDB实例不存在.

Exception Details: System.Data.SqlClient.SqlException: 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: 50 - Local Database Runtime error occurred. The specified LocalDB instance does not exist.

我该如何解决问题?

推荐答案

由于您更改了环境,例如本地笔记本电脑到产品服务器

Since you changed environments, for e.g. local laptop to prod server

对于生产环境,请检查并更新您的数据目录.

For production, check and update your data directory.

数据源=(LocalDB)\ MSSQLLocalDB; AttachDbFilename = | DataDirectory | \ SeedDb.mdf;集成安全性= True; MultipleActiveResultSets = True;".

"Data Source = (LocalDB)\MSSQLLocalDB; AttachDbFilename =|DataDirectory|\SeedDb.mdf; Integrated Security=True;MultipleActiveResultSets=True;".

调试硬编码目录路径,如果可以,则可以为 = | DataDirectory | \ SeedDb.mdf 设置环境变量然后在安全性(右键单击文件夹)下的目录中检查服务器/角色

to debug Hard code the directory path, if it works you can set you env variable for =|DataDirectory|\SeedDb.mdf Then check server/roles for the dir under security (right click folder)

这篇关于本地数据库错误.建立与SQL Server的连接时发生与网络相关或特定于实例的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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