简体   繁体   English

C#SQL Server身份验证字符串

[英]C# SQL Server authentication string

The IT changed the SQL Server to a new Microsoft SQL Server 2017, and some apps stopped working. IT将SQL Server更改为新的Microsoft SQL Server 2017,并且某些应用程序停止运行。 These apps (C#) use a connection string like this: 这些应用程序(C#)使用如下连接字符串:

SqlConnection conn = new SqlConnection("Data Source=192.168.100.101;Initial Catalog=Warehouse;Persist Security Info=True;User ID=****;Password=******");

But the new server works with Windows authentication. 但是新服务器可以使用Windows身份验证。 I'd like to know how to change the authentication for the new SQL Server to make apps work again. 我想知道如何更改新SQL Server的身份验证以使应用程序再次运行。

Thanks guys. 多谢你们。

In that case you can use the Integrated Security options, so the windows account that is running your C# program will be used 在这种情况下,您可以使用集成安全性选项,因此将使用运行C#程序的Windows帐户。

SqlConnection conn = new SqlConnection("Data Source=192.168.100.101;Initial Catalog=Warehouse;Integrated Security=True");

More info here https://docs.microsoft.com/en-us/dotnet/api/system.data.sqlclient.sqlconnection.connectionstring?view=netframework-4.7.2 此处的更多信息https://docs.microsoft.com/zh-cn/dotnet/api/system.data.sqlclient.sqlconnection.connectionstring?view=netframework-4.7.2

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

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