Asp.net 如何将SQL连接字符串从服务器更改为Windows身份验证

Asp.net 如何将SQL连接字符串从服务器更改为Windows身份验证,asp.net,sql-server,connection-string,Asp.net,Sql Server,Connection String,目前,我的项目使用此连接字符串连接到学校网络上的数据库 <connectionStrings> <add name="Provider" connectionString="server=.;uid=sa;pwd=****;database=decider;"/> </connectionStrings> 但我家的数据库使用Windows身份验证。 如何更改它?删除uid=sa和pwd=***添加Trusted\u

目前,我的项目使用此连接字符串连接到学校网络上的数据库

<connectionStrings>
<add name="Provider" connectionString="server=.;uid=sa;pwd=****;database=decider;"/>
</connectionStrings>

但我家的数据库使用Windows身份验证。
如何更改它?

删除
uid=sa
pwd=***
添加
Trusted\u Connection=True的键/值对

<add name="Provider" connectionString="server=.;database=decider;Trusted_Connection=True;"/>
SqlConnectionStringBuilder scb = new SqlConnectionStringBuilder(yourConnectionFromConfig);
scb.Remove("uid");
scb.Remove("pwd");
scb.IntegratedSecurity = true;
string yourNewConnectionString = scb.ToString();