Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

IDbConnection.ConnectionString Property

Definition

Namespace:
System.Data
Assemblies:
netstandard.dll, System.Data.Common.dll
Assembly:
System.Data.Common.dll
Assembly:
System.Data.dll
Assembly:
netstandard.dll
Source:
IDbConnection.cs
Source:
IDbConnection.cs
Source:
Operators.cs

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Gets or sets the string used to open a database.

public:
 property System::String ^ ConnectionString { System::String ^ get(); void set(System::String ^ value); };
public string ConnectionString { get; set; }
member this.ConnectionString : string with get, set
Public Property ConnectionString As String

Property Value

A string containing connection settings.

Examples

The following example creates an instance of a derived class, OleDbConnection, sets its ConnectionString, and displays its State.

public void CreateOleDbConnection(){
 OleDbConnection connection = new OleDbConnection();
 connection.ConnectionString =
 "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Northwind.mdb";
 Console.WriteLine("Connection State: " + connection.State.ToString());
}
Public Sub CreateOleDbConnection()
 Dim connection As New OleDbConnection()
 connection.ConnectionString = _
 "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Northwind.mdb"
 Console.WriteLine("Connection State: " & connection.State.ToString())
End Sub

Remarks

The ConnectionString property can be set only while the connection is closed.

Applies to


Feedback

Was this page helpful?