简体   繁体   English

SQL Server 2008和连接字符串

[英]SQL Server 2008 and Connection String

I have created a login in SQL Server 2008 with username= smart_provider and password = password. 我在SQL Server 2008中使用username = smart_provider和password = password创建了一个登录名。

Now, I added the following connection string to my project: 现在,我将以下连接字符串添加到我的项目中:

<add name="DB_Connection" 
     connectionString="data Source=.\MATTHEW;Initial Catalog=Provider;User Id=smart_provider;Password=password;Integrated Security=True" 
     providerName="System.Data.SqlClient"/>

Now, for some reason or another, even if I change the password to an incorrect one, the program still works and fetches the data from the database? 现在,由于某种原因,即使我将密码更改为不正确的密码,程序仍然可以工作并从数据库中提取数据? What am I doing wrong please? 我做错了什么? Thank you 谢谢

因为您有Integrated Security=True" 。如果您需要使用密码,请将其更改为false。

Set Integrated Security=false; 设置Integrated Security=false;

"Integrated Security" or "Trusted_Connection" When false, User ID and Password are specified in the connection. “Integrated Security”或“Trusted_Connection”如果为false,则在连接中指定用户ID和密码。 When true, the current Windows account credentials are used for authentication. 如果为true,则使用当前Windows帐户凭据进行身份验证。 If User ID and Password are specified and Integrated Security is set to true, the User ID and Password will be ignored and Integrated Security will be used. 如果指定了用户ID和密码并且Integrated Security设置为true,则将忽略用户ID和密码,并将使用Integrated Security。

Change Integrated Security to false and it will fail. 将Integrated Security更改为false,它将失败。 MS Docs: MS Docs:

When false, User ID and Password are specified in the connection. 如果为false,则在连接中指定用户ID和密码。 When true, the current Windows account credentials are used for authentication. 如果为true,则使用当前Windows帐户凭据进行身份验证。 Recognized values are true, false, yes, no, and sspi (strongly recommended), which is equivalent to true. 识别的值是true,false,yes,no和sspi(强烈推荐),这相当于true。

Make Integrated Security = false and you should be good. 使综合安全=假,你应该是好的。

Integrated Security = False : User ID and Password are specified in the connection. Integrated Security = False:在连接中指定用户ID和密码。 Integrated Security = true : the current Windows account credentials are used for authentication. Integrated Security = true:当前Windows帐户凭据用于身份验证。

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM