This documentation is archived and is not being maintained.

IDbConnection.ConnectionString Property

Gets or sets the string used to open a database.

Namespace: System.Data
Assembly: System.Data (in

string ConnectionString { get; set; 
/** @property */
String get_ConnectionString ()

/** @property */
void set_ConnectionString (String value)

function get ConnectionString () : String

function set ConnectionString (value : String)

Property Value

A string containing connection settings.

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

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());

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0