Hi friends,
I am unable to connect to the sqlserer from the .net project,getting the following 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: 26 - Error Locating Server/Instance Specified)
This exception was originally thrown at this call stack:
[External Code]
DataAccess.GenericRepository
Services.UserServices.GetUsers.AnonymousMethod__0() in UserServices.cs
[External Code]
This exception was originally thrown at this call stack:
[External Code]
DataAccess.GenericRepository
Services.UserServices.GetUsers.AnonymousMethod__0() in UserServices.cs
[External Code]
public List
{
return db.Set
}
The sql connection is working but not working from the project.
Please tell me how to resolve the issue.
prasanna pPosted Jun 16, 2023, 9:11 AM
Hi Friends,
1) I checked after adding Persist Security Info in the connection string but not working.
2) The sql server is running in the services
Any other solutions to fix this.
Vishal JoshiPosted Jun 16, 2023, 5:35 AM
Hello,
Please try replacing the below connection string in web.config file.
Make sure the below items:
Database Name: DV
Username and Password.
Thanks
Mudzakkir TohaPosted Jun 16, 2023, 2:54 AM
can you make sure SQLEXPRESS service is on ? You can find it on Task Manager - Services
If you are not so sure is your instance still health you can also install new version sql server developer edition. free to use for personal.
Tuhin PaulPosted Jun 16, 2023, 2:00 AM
You are experiencing a network-related or instance-specific error while trying to establish a connection to SQL Server from your .NET project. The error message suggests that the server was not found or is not accessible. It advises you to verify the correctness of the instance name and ensure that SQL Server is configured to allow remote connections.
The specific exception is being thrown in the
Get_StoredProcmethod of theGenericRepository.csfile in theDataAccessnamespace. The error occurs when trying to execute the SQL stored procedure using theFromSqlmethod. You mentioned that the SQL connection itself is working, it seems to be failing when accessed from the project. This indicates that the issue might be related to the project's configuration or network settings rather than the SQL Server itself.prasanna pPosted Jun 16, 2023, 1:24 AM
hi Mudzakkir Toha,
Web.config file connection string :
Mudzakkir TohaPosted Jun 15, 2023, 11:10 PM
can you post connection string here?
Is the conn sring is changed on the fly?
Is there any firewall blocking some port at the computer?