SqlCeConnection 建構函式
初始化 SqlCeConnection 類別的新執行個體。
命名空間: System.Data.SqlServerCe
組件: System.Data.SqlServerCe (在 System.Data.SqlServerCe.dll 中)
語法
'宣告
<SecurityTreatAsSafeAttribute> _
<SecurityCriticalAttribute> _
Public Sub New
'用途
Dim instance As New SqlCeConnection()
[SecurityTreatAsSafeAttribute]
[SecurityCriticalAttribute]
public SqlCeConnection()
[SecurityTreatAsSafeAttribute]
[SecurityCriticalAttribute]
public:
SqlCeConnection()
[<SecurityTreatAsSafeAttribute>]
[<SecurityCriticalAttribute>]
new : unit -> SqlCeConnection
public function SqlCeConnection()
備註
在建立 SqlCeConnection 的新執行個體時,讀取/寫入屬性會設定為下列的初始值,除非藉由使用 ConnectionString 屬性中與其相關的關鍵字特別加以設定。
屬性 |
初始值 |
---|---|
空字串 ("") |
|
空字串 ("") |
您只能藉由使用 ConnectionString 屬性來變更這些屬性的值。
範例
下列範例會建立並開啟 SqlCeConnection。
Dim conn As New SqlCeConnection()
' Set some connection string properties e.g.:
'
conn.ConnectionString = _
"Persist Security Info = False; Data Source = 'SalesData.sdf';" & _
"Password = '<password>'; File Mode = 'shared read'; " & _
"Max Database Size = 256; Max Buffer Size = 1024"
conn.Open()
' You can change the database while preserving
' the orignal connection options
'
conn.ChangeDatabase("SupportData.sdf")
SqlCeConnection conn = new SqlCeConnection();
// Set some connection string properties e.g.:
//
conn.ConnectionString =
"Persist Security Info = False; Data Source = 'SalesData.sdf';" +
"Password = '<password>'; File Mode = 'shared read'; " +
"Max Database Size = 256; Max Buffer Size = 1024";
conn.Open();
// You can change the database while preserving
// the orignal connection options
//
conn.ChangeDatabase("SupportData.sdf");