Share via


SqlCeConnection 构造函数 ()

初始化 SqlCeConnection 类的新实例。

命名空间: System.Data.SqlServerCe
程序集: System.Data.SqlServerCe(在 system.data.sqlserverce.dll 中)

语法

声明
Public Sub New
用法
Dim instance As New SqlCeConnection
public SqlCeConnection ()
public:
SqlCeConnection ()
public 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");

平台

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

Windows Vista、Microsoft Windows XP SP2 和 Windows Server 2003 SP1 支持 Microsoft .NET Framework 3.0。

版本信息

.NET Framework

受以下版本支持:3.0

.NET Compact Framework

受以下版本支持:2.0、1.0

请参见

参考

SqlCeConnection 类
SqlCeConnection 成员
System.Data.SqlServerCe 命名空间