ASP.NET Web Site Administration Tool: Cannot Connect to SQL Server Database

I am trying to get authentication and authorization while working with my ASP MVC project. I run the aspnet_regsql.exe tool without any problems and see the aspnetdb database on my server (using the Management Studio tool).

my connection string in my web.config:

 <connectionStrings>
 <add name="ApplicationServices"
     connectionString="data source=MYSERVERNAME;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"
     providerName="System.Data.SqlClient" />
 </connectionStrings> 

The error I am getting is:

There is a problem with the selected data store. This may be due to an incorrect server name or credentials or insufficient permission. This could also be because the role manager function is not enabled. Click the button below to redirect to a page where you can select a new data warehouse.

: SQL Server.

, . - ?

Edit . VS2010, ASP MVC2, SServer 2008

<connectionStrings>
<add name="ApplicationServices"
     connectionString="data source=MYSERVERNAME;Integrated Security=True;Initial Catalog=aspnetdb"
     providerName="System.Data.SqlClient" />
</connectionStrings>
+3
2

"MYSERVER", SQl, Sql Express. , AttachDbFilename SQL-. "\ SQLEXPRESS" ( ) , AttachDbFileName Database = "NAMEOFDATABASE"

+1

, , ASPNET (Machine_X\ASPNET Network Service) db, , :

-- Grant ASPNET access to the database
USE [##DBNAME##]
GO 

-- Grant login to Network service for ASPNET membership
EXEC sp_grantlogin N'##SERVICEACCOUNT##'
go

-- Grant minimum permissions
USE [##DBNAME##]
GO 
sp_addrolemember 'aspnet_Membership_FullAccess', N'##SERVICEACCOUNT##'
GO
0

Source: https://habr.com/ru/post/1755236/


All Articles