我在Web.Config中定义的连接字符串当前表示不需要用户或密码:
<connectionStrings>
<add name="CinemaxConnectionString" connectionString="Data Source=PCName\SQLEXPRESS;Initial Catalog=Cinemax;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
我想添加用户名和密码,如下所示:
<connectionStrings>
<add name="CinemaxConnectionString" connectionString="Data Source=PCName\SQLEXPRESS;Initial Catalog=Cinemax;User=cinemax; Password=abc"
providerName="System.Data.SqlClient" />
</connectionStrings>
显然,这需要更改Sql Server中的一些设置以添加用户和密码。做这个的最好方式是什么?我指定我有Sql Server 2005 Express,当前的身份验证模式是&#34; Sql Server和Windows身份验证&#34; 。 预先感谢您的帮助。 很高兴看到对此的双重看法:用户界面和代码解决方案。
答案 0 :(得分:13)
以下陈述将为您完成工作。
CREATE LOGIN cinemax WITH PASSWORD = 'abc';
GO
CREATE USER cinemaxUser FOR LOGIN cinemax
GO
GRANT SELECT TO cinemaxUser
GO
GRANT INSERT TO cinemaxUser
GO
GRANT UPDATE TO cinemaxUser
GO
GRANT DELETE TO cinemaxUser
GO