SqlConnection
SqlConnection is a data access class in the .NET data provider for SQL Server. It represents an open session to a SQL Server database and is used to establish a connection that can be used by commands to execute queries and other operations. In the .NET Framework and .NET Platform, it is provided by the System.Data.SqlClient namespace; in newer .NET projects the Microsoft.Data.SqlClient package is commonly used as a successor.
A SqlConnection exposes properties such as ConnectionString, Database, DataSource, ServerVersion, and State. Its primary operations are
Connection strings encode server address, database name, and authentication and security options. Typical parameters include Data
Usage best practices emphasize acquiring the connection late, enclosing it in a using block (or ensuring disposal)
Security considerations include using integrated security when possible, handling credentials securely, and enabling encryption if required