Share via


SqlCeConnection Constructor ()

Note: This namespace, class, or member is supported only in version 1.1 of the .NET Framework.

Initializes a new instance of the SqlCeConnection class.

  [Visual Basic]
  Public Sub New()

  [C#]
  public SqlCeConnection();

  [C++]
  public: SqlCeConnection();

  [JScript]
  public function SqlCeConnection();

Remarks

When a new instance of SqlCeConnection is created, the read/write properties are set to the following initial values unless they are specifically set by using their associated keywords in the ConnectionString property.

Properties Initial Value
ConnectionString empty string ("")
DataSource empty string ("")

You can change the value for these properties only by using the ConnectionString property.

Example

[Visual Basic, C#] The following example creates and opens a SqlCeConnection.

  [Visual Basic] 
Dim conn As New SqlCeConnection()
conn.ConnectionString = "Persist Security Info=False; Data Source = Northwind.sdf;" + _
  "Password = <password>; server=mySQLServer;Connect Timeout=30"

conn.Open()

[C#] 
SqlCeConnection conn = new SqlCeConnection();
conn.ConnectionString = "Persist Security Info=False; Data Source = Northwind.sdf;" + 
    "Password = <password>; server=mySQLServer;Connect Timeout=30";

conn.Open();

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: .NET Compact Framework

.NET Framework Security:

See Also

SqlCeConnection Class | SqlCeConnection Members | System.Data.SqlServerCe Namespace | SqlCeConnection Constructor Overload List

Syntax based on .NET Framework version 1.1.
Documentation version 1.1.1.

Send comments on this topic.

© Microsoft Corporation. All rights reserved.