Mono Class Library: System.Data.SqlClient.SqlConnection Overview | Members

System.Data.SqlClient.SqlConnection.ConnectionString Property

Gets or sets the database Connection String associated with the SqlConnection instance.

[System.ComponentModel.RefreshProperties(System.ComponentModel.RefreshProperties.All)]
[System.ComponentModel.RecommendedAsConfigurable(true)]
[System.ComponentModel.Editor("Microsoft.VSDesigner.Data.SQL.Design.SqlConnectionStringEditor, Microsoft.VSDesigner, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[System.ComponentModel.DefaultValue("")]
public override string ConnectionString { set; get; }

Value

The current connection string.

Remarks

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.

Requirements

Namespace: System.Data.SqlClient
Assembly: System.Data (in System.Data.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0