Reputation: 177
When connecting to SQL Server error occurred with the network or to a specific instance
The server was not found or is not available. Verify that the instance name is spelled correctly and that SQL Server allow remote connections. provider: SQL Network Interfaces, error: 26 - Error detection specified server or instance.
The connection string to the database:
<add name="RequirementContext"
connectionString="Data Source=RU-DEV24;Initial Catalog=OpenSoft.AgileAnalytics.EF;Integrated Security=True;MultipleActiveResultSets=True"
providerName="System.Data.SqlClient" />
I can not understand, which is why this error occurs. Help please!
Code in which an error
public class Permission
{
public string RoleString
{
get
{
return string.Join(", ", UserRoles);
}
}
public int UserId { get; set; }
public string UserName { get; set; }
public List<string> UserRoles { get; set; }
public static Permission CreateFromUserProfile(UserProfile userProfile)
{
//here
return new Permission
{
UserId = userProfile.UserId,
UserName = userProfile.UserName,
UserRoles = Roles.GetRolesForUser(userProfile.UserName).ToList(),
};
}
}
!!!! The problem was solved. I just added to file web.config this code:
<roleManager enabled="true" defaultProvider="SimpleRoleProvider">
<providers>
<clear />
<add name="SimpleRoleProvider" type="WebMatrix.WebData.SimpleRoleProvider,WebMatrix.WebData" />
</providers>
</roleManager>
<membership defaultProvider="SimpleMembershipProvider">
<providers>
<clear />
<add name="SimpleMembershipProvider" type="WebMatrix.WebData.SimpleMembershipProvider, WebMatrix.WebData" />
</providers>
</membership>
Upvotes: 1
Views: 6456
Reputation: 1686
Make sure that your database engine is accepting remote connections:
Enable TCP/IP in SQL Server Configuration:
Make sure that the SQL Browser service is running:
Configure your windows firewall to allow access :
Upvotes: 2
Reputation: 161
Common causes of this error:
If you're using SQL Express, you should probably have "SQLEXPRESS" as the instance name for your server.
Upvotes: 0