2011-10-22 3 views
0

SQL Server Express를 통해 ASP.NET 멤버십을 사용하는 데 문제가 있습니까?ASP.NET 멤버 자격 공급자 SQL Server Express

이 코드를 사용하는 경우 :

Roles.AddUserToRole("shah", "Admdin") 

나는 아래와 같은 에러에 직면하고있다.

구성은 :

OS : windows 7 64 bit.
SQL Server version: SQL Server Express Edition, Version :9.00.4035.00

connectionString="Data Source=.\sqlexpress;Initial Catalog=MShop;Integrated Security=True" 

The user instance login flag is not supported on this version of SQL Server. The connection will be closed. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

SQLExpress database file auto-creation error:

The connection string specifies a local Sql Server Express instance using a database location within the application's App_Data directory. The provider attempted to automatically create the application services database because the provider determined that the database does not exist. The following configuration requirements are necessary to successfully check for existence of the application services database and automatically create the application services database:

If the application is running on either Windows 7 or Windows Server 2008R2, special configuration steps are necessary to enable 

automatic creation of the provider database. Additional information is available at: http://go.microsoft.com/fwlink/?LinkId=160102 . If the application's App_Data directory does not already exist, the web server account must have read and write access to the application's directory. This is necessary because the web server account will automatically create the App_Data directory if it does not already exist. If the application's App_Data directory already exists, the web server account only requires read and write access to the application's App_Data directory. This is necessary because the web server account will attempt to verify that the Sql Server Express database already exists within the application's App_Data directory. Revoking read access on the App_Data directory from the web server account will prevent the provider from correctly determining if the Sql Server Express database already exists. This will cause an error when the provider attempts to create a duplicate of an already existing database. Write access is required because the web server account's credentials are used when creating the new database. Sql Server Express must be installed on the machine. The process identity for the web server account must have a local user profile. See the readme document for details on how to create a local user profile for both machine and domain accounts.

+1

ASP.NET 역할 하위 시스템이 참조하는 연결 문자열은 무엇입니까 ?? 그것은 내가 보여준 것보다 다른 연결 문자열을 참조하는 것 같습니다. –

+0

@marc_s 네, 맞습니다 선생님 :). – Shahin

답변

1

예, SQL Express를 회원 자격을 사용할 수 있습니다. 내 생각에 당신은 web.config에 제대로 구성된 롤이 없다고 생각합니다. 이 오류는 데이터베이스를 만들려고 시도 중이지만 사용자에게 역할을 추가하려는 경우 데이터베이스가 이미 있어야 함을 나타냅니다.

데이터베이스를 만들지 않으면 사용자를 먼저 만든 다음 역할에 추가해야합니다 존재하지 않으면 사용자를 먼저 만들지 않았거나 존재하지 않는 데이터베이스를 사용하도록 역할을 구성했습니다.

관련 문제