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
只能在连接关闭时设置 属性。