【问题标题】:how to fix The system cannot find the file specified error in ASP.NET MVC and sql server 2019如何解决 ASP.NET MVC 和 sql server 2019 中系统找不到文件指定错误
【发布时间】:2020-05-12 17:00:01
【问题描述】:

我创建代码第一个应用程序,但我运行应用程序收到此错误,它不会生成 db

使用 sql server 2019 请帮我 我跑不了

    Server Error in '/' Application.
The system cannot find the file specified
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.ComponentModel.Win32Exception: The system cannot find the file specified

Source Error:


Line 71:             // This doen't count login failures towards lockout only two factor authentication
Line 72:             // To enable password failures to trigger lockout, change to shouldLockout: true
Line 73:             var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false);
Line 74:             switch (result)
Line 75:             {

Source File: G:\MvcProject\OPA finally\OPA finally\Controllers\AccountController.cs    Line: 73

Stack Trace:


[Win32Exception (0x80004005): The system cannot find the file specified]

[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: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.)]
   System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, 
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4075.0

我的连接字符串是真的,但我没有工作 web.config 连接字符串代码:


<connectionStrings>
    <add name="DefaultConnection" connectionString="Data Source=.;Initial Catalog=DefaultConnection;Integrated Security=True;" providerName="System.Data.SqlClient" />
    </connectionStrings>

谢谢你的回答

【问题讨论】:

    标签: asp.net asp.net-mvc entity-framework


    【解决方案1】:

    首先检查 SQL Server 代理是否正在运行。

    大多数情况下,这意味着连接字符串不完整。如果您不使用 Windows 身份验证,则需要提供 uid=YourUserName;密码=您的密码;。检查 sql server db 中的登录名(导航到安全 > 登录名)。

    否则尝试在连接字符串中指定服务器名称。如果你有一个命名实例,那么你应该像这样设置它,即Server=localhost\sql2019

    InitialCatalog 也是数据库的名称。是“默认连接”吗?

    还可以查看您的数据库中的属性。

    【讨论】:

    • 我使用windows认证
    • 我更新了我的答案。尝试指定服务器名称。
    • 我用 (( )) 但我的错误仍然存​​在!
    • sql server 实例的名称是什么。看看服务。
    • 而且 InitialCatalog 是数据库的名称。是“默认连接”吗?
    猜你喜欢
    • 1970-01-01
    • 2020-03-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-20
    相关资源
    最近更新 更多