prasanna p

prasanna p

  • 1.2k
  • 465
  • 97.2k

Getting connection error in the DataAccess layer

Jun 15 2023 4:48 PM

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<T>.Get_StoredProc(string) in GenericRepository.cs
    Services.UserServices.GetUsers.AnonymousMethod__0() in UserServices.cs
    [External Code]
This exception was originally thrown at this call stack:
    [External Code]
    DataAccess.GenericRepository<T>.Get_StoredProc(string) in GenericRepository.cs
    Services.UserServices.GetUsers.AnonymousMethod__0() in UserServices.cs
    [External Code]

public List<T> Get_StoredProc(string sPName)
        {
            return db.Set<T>().FromSql(sPName).ToList(); ---> Getting Connection error in the DataAccess genericRepository file.
        }

The sql connection is working but not working from the project.

Please tell me how to resolve the issue.

 


Answers (6)