Export (0) Print
Expand All

IDbConnection.ConnectionString Property

Gets or sets the string used to open a database.

Namespace: System.Data
Assembly: System.Data (in system.data.dll)

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

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

function get ConnectionString () : String

function set ConnectionString (value : String)

Not applicable.

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 Server 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 Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0

Community Additions

ADD
Show:
© 2014 Microsoft