Cannot connect to database after installing Nuget Package Microsoft.Asp.Net.Webhelpers - c#

I am having an issue with connecting to any of my databases after installing Microsoft.Asp.Net.Webhelpers. I have uninstalled it and still having an issue:
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: 26 - Error Locating
Server/Instance Specified)
My live site uses this database and is up and working. It does the same thing when I use my local machine connection. Does anyone know what this package may have changed in my project to cause this? I appologize if this is not the correct place to put it, I really do not know what code needs to be posted because everything was working fine before installing this package..
Thanks for your help!
UPDATE:
I am now showing an error that I need to restore with nuget package manager. Something is missing. It is set to automatically update missing packages but for some reason it doesn't. So I closed the program and will reboot my system and see what happens when I reopen and try to rebuild. I will do a clean first.
UPDATE:
The Problem package appears to be Microsoft.AspNet.Webpages.data which is a dependancy of `Microsoft.AspNet.WebHelpers. As soon as I install this package I loose database connectivity. I have not found any information on this issue anywhere. It seems strange to me because Microsoft has it under the latest version of .net. Which i am using..

Related

Unable to connect to LocalDB from ASP.NET Core

I'm trying to setup a database for my ASP.NET Core Web Application. Unfortunately each time I try to run dotnet ef Database Update, I get this error:
Error Number:-1983577829,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: SNI_PN11, error: 50 - Local Database Runtime err
or occurred. Specified LocalDB instance name is invalid.)
I've tried everything I can think of, and have reinstalled multiple times. I've installed Visual Studio 2019 with LocalDB, 2022 with LocalDB, LocalDB by itself, SQLExpress with LocalDB, and it all has not worked. I've even reset my PC, which unfortunately has still not changed anything.
Here is my connection string:
"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=PROJECT_NAME_HERE;Trusted_Connection=True;MultipleActiveResultSets=true"
And I am utilizing the connection string with this:
services.AddDbContext<ApplicationDbContext>(options =>
{
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"));
});
I should mention that this connection string has worked in the past.
Any help would be appreciated! Thanks :D
I received the same error message on Windows 11. I removed the escaping backslash and it worked.
Instead of:
"Server=(localdb)\\mssqllocaldb;Database=PROJECT_NAME_HERE;Trusted_Connection=True;MultipleActiveResultSets=true"
This:
"Server=(localdb)\mssqllocaldb;Database=PROJECT_NAME_HERE;Trusted_Connection=True;MultipleActiveResultSets=true"
Would be nice to know if this is really a Windows 11 issue, but I currently don't want to dig deeper.
You probably need to re-create your LocalDB instance. I once had a similar issue when I tried to uninstall and reinstall localdb and sql server express.
You could try running the following command in PowerShell
SqlLocalDB.exe create "MsSQLLocalDB" 12.0 -s
That should create an instance of localdb called "MSSQLLocalDB". You can then use the connection string "Server=(localdb)\\MSSQLLocalDB;Database=PROJECT_NAME_HERE;Trusted_Connection=True;MultipleActiveResultSets=true"
See This MSDN page for more information regarding LocalDB Instances. You could also read more about how localdb works on this MSDN page
After more and more Googling and researching, I found someone on Reddit that is having a very similar issue, with the same error message through the Event Viewer. The common ground between us is Windows 11, we've both exhausted all of our options.
I thought it might have been because I was on Windows 11, but I thought the chances of that were very minor. I guess it is though. My apologies!
Tl;dr: The assumption is that Windows 11 is not working properly with the SQL Installations.

ASP.NET application SQL connection error from production server

During development on my local computer, I am able to connect to the remote (Production) SQL Server with no issues, but when I deploy the application to said production server, I get this error:
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.
I have done I believe all the things suggested to resolve this problem with no success. Please help if you can. Thanks!
I figured out the answer to my issue. I am using ASP.NET Identity and it created it's own connection but I wanted to use my own database. When I deployed my application that connection was broken. Changed the Identity connection to my own database connection and all worked as expected.

Stumped trying to connect IIS 7 to my localdb running inside of Visual Studio 2015

For the life of me I am unable to connect to my localdb hosted database created in Visual Studio 2015 to my local IIS 7 instance running on the same machine. IIS Express works fine but when I wanted to test things as a user outside of my network I dabbled with a Local copy of IIS.
I have tried everything from ensuring the app pools have the right privileges, that my connection strings are accurate and just about every thing else I have found on the web but I cannot for the life of me get this working.
The error I am getting is the following: 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. Cannot get a local application data path. Most probably a user profile is not loaded. If LocalDB is executed under IIS, make sure that profile loading is enabled for the current user.
)
Connection String in VS2015:
Any other details needed to help troubleshoot ask and I will provide.
Thank you in advance for reading.

Creating a Service Based Database in Visual Studio

I am having problems creating a Service Based Database on Visual Studio 2013 Community.
Basically, the problem is that when I attempt to add a Service Based Database to any of my projects I get an error message:
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.
Cannot create an automatic instance. See the Windows Application event
log for error details)
In the past I have been able to add Databases to my projects without any issues. What has changed between now and then is that I started using SQL Server 2014 to work with a Java Project. I assume that installing SQL Server 2014 has changed some configuration settings that are now preventing me from creating a local database in Visual Studio.
I was able to resolve this by changing the name of the server (as configured in Visual Studio through Tools>Options>Database Tools>Data Connections) to SQLEXPRESS and was able to create a database, however, when I went to create a data source from the database, I got to the final step before I got the message:
Could not load file or assembly
'Microsoft.SqlServer.Management.Sdk.Sfc, Version=11.0.0.0,
Culture=neutral, PublicKeyToken or one of its dependencies. The system
cannot find the file specified
After downloading some files and installing them I saw no effects. I really still want to use a local database, and after trying to return back to using a local database I can't get anything at all to work. Now, no matter what I try I get the error message:
A network-related or instance-specific error occured while
establishing a connection to SQL Server. The server was not found or
wa 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)
If I want to work with local databases in Visual Studio, can I do this with SQL Server 2014 installed? If so, is there anywhere that I am going wrong?
Thank you very much for any help you can provide.
Ok so I managed to fix my problem.
To create a local database I had to use the SQL Server Instance name (localDB)\v11.0 and install 2012 LocalDB. It would appear as though installing SQL Server 2014 updated the 2012 version of LocalDB to a 2014 version, which Visual Studio 2013 is not compatible with.
I would thank everyone for the help, but there is no-one to thank.
Try running Visual Studio 2013 as administrator. It worked for me.
I found here ( A network-related or instance-specific error occurred while establishing a connection to SQL Server ) that the error is related with rights accessing databases.

Visual Studio 2010 SQL Developement Server stopped working

I was making minor modifications to a view in my ASP.NET MVC 3 C# application when all of a sudden the application would no longer run. The error message is as follows:
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: Shared Memory Provider, error: 40 - Could not open a connection to SQL Server)
Upon close inspection of the server explorer I noticed that all database connections are no longer working. I cannot expand any of the connections to view the tables and data I previously generated within. When I attempt to, there is a pop-up window that is generated that repeats the exact same error as above.
It is important to note that I was not making any modifications to any portion of the application that pertains to a database. I was rearranging some of the visual components of a view in my application when all of this occurred. I had just recently restarted my computer and had made no other modifications since that time.
At first I thought that somehow SQL Express had overwritten my development environments version of SQL Server and began to reinstall SQL Server Express. The installation fails every time now. There is no specific error. Windows generates an error message saying that the setup application "stopped working" and hangs until closed.
I have tried several different versions of the SQL Server Express installation package, and they all result in the same error happening at different points in the installation process. To be clear, I'm not even sure SQL Server Express is the problem. I don't know why it would be since I'm using the SQL Server edition that is built into Visual Studio 2010.
Is the SQL service running? Check under SQL Server Configuration Manager.
Yes, another life saved.
Run-sqlservermanager11.msc, right click and start.
Is the SQL service running? Check under the SQL Server Configuration Manager.
I assume you've already tried to repair install, to uninstall and to restart your computer, pray then try again?
Are you databases remotely deployed? Because it is possible that the network is down.
Secondly, check in the we.config file if you have specified the correct credentials. Try to log in through SQL Server Management Studio.
One more thing: Stop the SQL Server service, and start it again. Or you can reboot the system.

Categories

Resources