0

Unable to connect to SQL & login in ASP.NET MVC web application.

But I am able to connect & retrieve all other data. Only login & register are not working. I don't know what's wrong.

Login:

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

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, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling, SqlAuthenticationProviderManager sqlAuthProviderManager) +1077
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) +802

Other Controller

  • Able to add/edit/delete any records.

Connection String

metadata=res://*/CouriersHubEntity.csdl|res://*/CouriersHubEntity.ssdl|res://*/CouriersHubEntity.msl;provider=System.Data.SqlClient;provider connection string="Data Source=xx.xx.xx.xx;Initial Catalog=CouriersHubDB;Persist Security Info=True;User ID=xxxxxx;Password=hidden;App=EntityFramework"
Aravin
  • 6,605
  • 5
  • 42
  • 58
  • Not related. @AkshayRaut – Aravin Dec 10 '18 at 10:54
  • 1
    Check if you have a **second** connection string that is used for all the Identity stuff, and if so, make it point to the same database as the 'main' connection string. Or refactor so Identity uses the main one. – Peter B Dec 10 '18 at 11:03
  • The duplicate is definitely related. One of your connection strings is pointing to a non-existing database server. As @Peter states, check how your Identity DbContext is being initialized. Probably with a connection string that points to a server not accessible from your web server. – CodeCaster Dec 10 '18 at 11:27

1 Answers1

-1

Your connection to sql server/database failed, please check your connectionstring, you can try to connect to sql server via management studio to make sure credentials are correct.

  • sometime we make a mistake by just putting local\dbserver in connectionstring, correct way is (localhost)\dbserver (sqlexpress or sqlserver in most cases)
Altaf
  • 189
  • 2
  • 4