2011-10-22 118 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中正確配置你的角色。錯誤表明它正在嘗試創建數據庫,但是如果您試圖向用戶添加角色,數據庫應該已經存在,您必須先創建用戶,然後將它們添加到角色中(如果數據庫不執行)如果你沒有先創建用戶,或者你的角色被配置爲使用不存在的數據庫,那麼就不存在。

相關問題