Gets or sets the database Connection String associated with the SqlConnection instance.
The current connection string.
The Connection String is a string value that describes how to connect to a SQL Server instance. The Connection String is composed of a series of name/value pairs connected by equal signs and separated by semicolons.
The SQL Server Connection String should consist of at least the following:
- Data Source or Server
- Database or Initial Catalog
The following illustrates a simple SQL Server Connection String that describes a connection to a database called pubs on the local machine as a user called username with a password of mypassword:
SQL Server Connection String Example
"Server=localhost;Database=pubs;Uid=username;Password=mypassword"Note: The Connection String can not be set when a connection to a database is already open.
Namespace: System.Data.SqlClient
Assembly: System.Data (in System.Data.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0