Many people may have encountered such a web. config connection string.
<ConnectionStrings>
<Add name = "SqlClient" providerName = "System. Data. SqlClient" connectionString = "Data Source = localhost; MultipleActiveResultSets = True; Initial Catalog = XXX; Integrated Security = True"/>
</ConnectionStrings>
No SQL id or pwd
Searched for information
In this way, the user name and password are not required to connect to the SQL Server, and the windows user is used for verification directly. This avoids exposing the Sa account and password.
After searching, we found that this method can also connect to the database in our horse. The statement is
Persist Security Info = False; Initial Catalog = database name; Data Source = SQL Server Name (localhost); Integrated Security = SSPI; Provider = SQLOLEDB.1
Copy this sentence to the location where the aspx horse connects to the database.
From Shadow Security Net