因为你的程序连接SQLServer的连接字符串是用了windows集成登陆,你可以改成用数据库帐号密码登陆。连接字符串的写法是:
server=localhost;uid=sa;pwd=xxxx;database=master;
server是数据库服务器的机器名或者IP,如果是同一台机可以用localhost
uid是数据库登陆帐号
pwd是数据库密码
database是数据库初始owner名称
对于我们的程序就是将下面的一句中的
server=.;database=onnetbooksell;uid=sa;pwd=;Trusted_Connection=yes
Trusted_Connection=yes去掉就可以了.
转载自:
http://publishblog.blogchina.com/blog/tb.b?diaryID=336088解决方案:
osql -S
COMPUTERNAME\VSDOTNET -E
USE
DATABASENAME EXEC sp_grantlogin '
COMPUTERNAME\ASPNET'
EXEC sp_grantdbaccess '
COMPUTERNAME\ASPNET'
EXEC sp_addrolemember 'db_owner', '
COMPUTERNAME\ASPNET'
go
原因:
The basic problem is that your SQL Server/MSDE database does not recognize the account name of the process running the Web page. ASP.NET applications run within the context of an account named
computer\ASPNET. When your code runs, it makes a request to the SQL Server/MSDE for a trusted connection as the user
computer\ASPNET. SQL Server/MSDE probably doesn't know who that is, so it refuses the connection.