把Sharepoint项目移植到另一个测试服务器上后(此服务器有测试用的数据库,项目要访问此测试数据库),运行代码时遇到 Microsoft SQL Server 2008 – Login failed for user ‘username’错误。这是因为代码在访问数据库时,没有建立起与数据库之间可信的数据连接(注:项目访问数据库是通过"域名\用户名" 来访问数据库的)。
错误信息如下
解决方法是:
把SQL Servere的Authentication Mode设置成: Both SQL Server and Windows Authentication Mode.
操作步骤是:Go to Start > Programs > Microsoft SQL Server 2008 > SQL Server Management Studio-->Right-click the Server name, select Properties > Security-->Under Server Authentication, select SQL Server and Windows Authentication Mode
设置完成后,必须重新启动服务器才能使刚才的改动生效。