IDbConnection.ConnectionString 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定用來開啟資料庫的字串。
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
屬性值
包含連線設定的字串。
範例
下列範例會建立衍生類別的實例、 OleDbConnection設定其 ConnectionString,並顯示其 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
備註
ConnectionString
只有在關閉連接時,才能設定 屬性。