我有一个网站,连接到SQLServer快速数据库文件的会员和数据storage.So我有两个.mdf文件。以下是连接字符串:
public static string ASPNETDB = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.mdf;Integrated Security=True;User Instance=True;User ID=;Password=; ";
public static string Dok = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\dok.mdf;Integrated Security=True;User Instance=True;User ID=;Password=; ";
现在,在删除并重新安装网站后,我在连接是established.Here的部分收到了许多错误,错误如下:
Unable to open the physical file "C:\Inetpub\wwwroot\BSHHD\App_Data\aspnetdb_log.ldf".
Operating system error 5: "5(failed to retrieve text for this error. Reason: 1815)".
Cannot open user default database. Login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
File activation failure. The physical file name "C:\Inetpub\wwwroot\BSHHD\App_Data
\aspnetdb_log.ldf" may be incorrect.
The log cannot be rebuilt because there were open transactions/users when the database
was shutdown, no checkpoint occurred to the database, or the database was read-only.
This error could occur if the transaction log file was manually deleted or lost due to
a hardware or environment failure.
这非常奇怪,因为我没有对网站做任何更改。我刚刚从IIS中删除了它并重新安装了它。有人建议我设置用户名和密码,并删除集成安全性。但是我不知道如何为数据文件设置用户名/密码。
发布于 2012-07-24 14:05:54
使用SQL Management studio将数据库ASPNETDB.mdf添加到SQL Express,您可以从Microsoft web平台安装程序下载它。
打开SQL Management studio,右键单击Databases > Attach > Add the mdf and log file (最好将它们放在其他位置,而不是站点目录。
在MSSQL中,您可以轻松地设置用户名和密码,打开SQL Management studio。
登录到Management studio:展开安全>登录>写入单击登录"New Login“
登录名:例如,logmein,Make it SQL Server Authentication,设置密码,删除强制
在左侧,您将让User Mapping选择要连接的数据库并授予写入权限,例如,如果此用户可以写入数据库,您将希望将其设置为具有更高权限的datawriter或db_owner:
数据库内置角色包括:
public -默认授权集
db_owner -允许执行指定数据库的任何操作
db_oddladmin -允许创建或修改数据库的新对象(所谓的DDL操作);您应该注意这样一个事实,即用户不必拥有
执行此操作的db_owner授权
db_datareader -允许读取任何表
db_datawriter -允许写入任何表
db_denydatareader -禁止读取表(公开授权外卖)
dDb_denydatawriter -禁止写入表
将数据库添加到SQL之后:可以在web.config中添加
<add name="ASPNETDB" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=ASPNETDB.mdf;User ID=yourusername;Password=yourpassword" providerName="System.Data.SqlClient" />
<add name="Dok " connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=dok.mdf;User ID=yourusername;Password=yourpassword" providerName="System.Data.SqlClient" />
或者,如果您更喜欢在代码中使用它,就像上面一样,它也可以工作。
问候你,加布里埃尔
https://stackoverflow.com/questions/11624655
复制相似问题