Share via


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

空字符串 ("")

DataSource

空字符串 ("")

只能使用 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");

请参阅

参考

SqlCeConnection 类

SqlCeConnection 重载

System.Data.SqlServerCe 命名空间