1

My aspnetdb database's (the database that get's created when you use asp.net's membership provider) windows file permissions keeps getting reset after a while. This happened on SQL Server 2005 Express and SQL Server 2008 Express.

The database is accessed via an asp.net website. When this happens, the website says login invalid and attempting to reset the password produces an error saying unsuccessful. When I examine the the windows file permissions for the aspnetdb.mdf, all the user and group permissions are gone. The only way to get things working again is by restoring the aspnetdb file from backup.

I've tried setting autoclose and autoshrink on the database to false and passing the -t1802 option to SQL Server and this problem still comes up from time to time. The website that accesses the database is running on IIS 7 and asp.net 3.5.

EDIT: My connections strings are:

<add name="LocalSqlServer" connectionString="data source=.\sqlexpress;Integrated Security=SSPI;initial catalog=aspnetdb"/>

<add name="ConnectionString" connectionString="Data Source=(local)\sqlexpress;Initial Catalog=NetDevices;Integrated Security=True" ProviderName="System.Data.SqlClient"/>

I am not dynamically attaching the database, I attach the aspnetdb.mdf file explicity in sql management express.

4

1 回答 1

2

在我看来,整个附加.mdf数据库文件的方法来使用 SQL Server 数据库是有严重缺陷的。

许多人都看到了许多潜在的问题——被重置的权限是一个新的、额外的问题。

在我看来,真正的解决方案

  1. 安装 SQL Server Express(如果你现在使用这种方法,你已经完成了)

  2. 安装 SQL Server Management Studio Express

  3. 在SSMS Express中创建您的数据库,给它一个逻辑名称(例如ASPNETDB

  4. 使用它的逻辑数据库名称(在服务器上创建它时给出)连接到它——不要乱用物理数据库文件和用户实例。在这种情况下,您的连接字符串将类似于:

    Data Source=.\\SQLEXPRESS;Database=ASPNETDB;Integrated Security=True
    

    其他一切都和以前完全一样......

于 2013-03-11T21:57:32.633 回答