SQL Server 2008 和连接字符串

3
我已经在SQL Server 2008中创建了一个用户名为smart_provider,密码为password的登录。
现在,我已将以下连接字符串添加到我的项目中:
<add name="DB_Connection" 
     connectionString="data Source=.\MATTHEW;Initial Catalog=Provider;User Id=smart_provider;Password=password;Integrated Security=True" 
     providerName="System.Data.SqlClient"/>

现在,无论我将密码更改为不正确的密码,该程序仍然可以正常工作并从数据库中获取数据?请问我做错了什么?谢谢。


你应该选择最佳答案作为已回答的问题 :) - logixologist
这是一个艰难的决定。它们都很好。如果可以的话,我会选择全部。 - Matthew
同意...我会说选择第一个回答,因为从技术上讲,他们都给出了相同的答案。 - logixologist
1
谢谢。正如我所说,我想标记它们全部。 - Matthew
4个回答

4

因为你设置了Integrated Security=True,如果需要使用密码,请将其更改为false。


3

设置 Integrated Security=false;

"Integrated Security" 或 "Trusted_Connection" 当为 false 时,需在连接中指定用户 ID 和密码。 当为 true 时,将使用当前 Windows 帐户凭据进行身份验证。 如果指定了用户 ID 和密码并且已将集成安全性设置为 true,则将忽略用户 ID 和密码,并使用集成安全性。


谢谢Amit :) 祝你编程愉快 :) - Matthew

2

将集成安全性改为false,它将失败。

当为false时,连接中指定了用户ID和密码。当为true时,使用当前Windows帐户凭据进行身份验证。 可识别的值为true、false、yes、no和sspi(强烈推荐),它等同于true。


2

将Integrated Security设置为false,就可以了。

Integrated Security = False:连接中指定了用户名和密码。Integrated Security = true:使用当前Windows帐户凭据进行身份验证。

希望这可以帮到你。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接