
"Persist Security Info=False Trusted_Connection=True "Persist Security Info=False Integrated Security=SSPI Initial Catalog=AdventureWorks Server=MSSQL1" "Persist Security Info=False Integrated Security=true

Windows authentication with SqlClientĮach of the following forms of syntax uses Windows Authentication to connect to the AdventureWorks database on a local server. Keep Persist Security Info set to false to ensure that an untrusted source does not have access to sensitive connection string information. Setting it to true or yes allows security-sensitive information, including the user ID and password, to be obtained from the connection after the connection has been opened. The default setting for the Persist Security Info keyword is false. The connection string keywords also map to properties in the SqlConnectionStringBuilder. You can use the ConnectionString property to get or set a connection string for a SQL Server database. The syntax for a SqlConnection connection string is documented in the SqlConnection.ConnectionString property. The following table shows the Windows Authentication syntax used with the Microsoft SqlClient Data Provider for SQL Server. We recommend using Windows Authentication (sometimes referred to as integrated security) to connect to data sources that support it.


For more information, see Connection String Builders. The connection string builders allow you to construct syntactically valid connection strings at run time, so you do not have to manually concatenate connection string values in your code. Microsoft SqlClient Data Provider for SQL Server introduced the following connection string builder. For more information on connection string syntax, see ConnectionString. The specific connection string syntax for the SqlClient provider is documented in its ConnectionString property.

The has a Connection object that inherits from DbConnection as well as a provider-specific ConnectionString property.
