gpt4 book ai didi

c# - 本地数据库错误。建立与 SQL Server 的连接时出现与网络相关或特定于实例的错误

转载 作者:行者123 更新时间:2023-11-30 13:06:14 25 4
gpt4 key购买 nike

我的网站使用本地数据库运行 Visual Studio 2015,一切正常。但是生产服务器不工作。

连接字符串是

"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.

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. )

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.

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.

我该如何解决这个问题?

最佳答案

因为你改变了环境,例如本地笔记本电脑到生产服务器

对于生产,检查并更新您的数据目录。

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

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

关于c# - 本地数据库错误。建立与 SQL Server 的连接时出现与网络相关或特定于实例的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33605628/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com