Monday, July 28, 2008

NDbUnit Framework

NDbUnit test is a good UnitTest framework if you are familiar with C#. But this project seems not active since 2006.
Home Page: http://qualitylabs.org/projects/ndbunit/

Monday, July 21, 2008

SQL 2005 Restore database error

当我用SQL Server 2005 restore一个数据库时候, 总是报下面的错. 我试着用sa登录,试着用Windows Authentication方式登录都不行.
System.Data.SqlClient.SqlError: The operating system returned the error '5(Access is denied.)' while attempting 'RestoreContainer::ValidateTargetForCreation' on 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DWH.mdf'. (Microsoft.SqlServer.Express.Smo)

google之后, 发现原因是SQL Server服务的账号必须有权限读写mdf文件. 而SQL Server 2005服务可以用指定的windows账号来启动, 仅仅内建的启动账号就有local system,local service和network service三种, 还可以用其他账号来启动.
出现restore错误时候, SQL Server2005是由network service账号来启动的, 该账号没有权限读写mdf文件. 所以需要切换启动账号, 可以用SQL Server configuration manager这个工具.

The service account for sqlexpress does not have access/permission. Use Configuration Mgr to change the startup account to LocalSystem (if your database and backup file are on the local machine) or a domain user account that has permission to disk resources (locally and remotely).