Not
Åtkomst till den här sidan kräver auktorisering. Du kan prova att logga in eller ändra kataloger.
Åtkomst till den här sidan kräver auktorisering. Du kan prova att ändra kataloger.
Note: This namespace, class, or member is supported only in version 1.1 of the .NET Framework.
Initializes a new instance of the SqlCeEngine class.
[Visual Basic] Public Sub New() [C#] public SqlCeEngine(); [C++] public: SqlCeEngine(); [JScript] public function SqlCeEngine();
Example
[Visual Basic, C#] The following sample demonstrates how to create a new SQL Server CE database.
[Visual Basic]
If File.Exists("Test.sdf") Then
File.Delete("Test.sdf")
End If
Dim connStr As String = "Data Source = Test.sdf; Password = <password>"
Dim engine As New SqlCeEngine(connStr)
engine.CreateDatabase()
engine.Dispose()
Dim conn As SqlCeConnection = Nothing
Try
conn = New SqlCeConnection(connStr)
conn.Open()
Dim cmd As SqlCeCommand = conn.CreateCommand()
cmd.CommandText = "CREATE TABLE myTable (col1 int, col2 ntext)"
cmd.ExecuteNonQuery()
Catch
Finally
conn.Close()
End Try
[C#]
if (File.Exists("Test.sdf"))
File.Delete("Test.sdf");
string connStr = "Data Source = Test.sdf; Password = <password>";
SqlCeEngine engine = new SqlCeEngine(connStr);
engine.CreateDatabase();
engine.Dispose();
SqlCeConnection conn = null;
try {
conn = new SqlCeConnection(connStr);
conn.Open();
SqlCeCommand cmd = conn.CreateCommand();
cmd.CommandText = "CREATE TABLE myTable (col1 int, col2 ntext)";
cmd.ExecuteNonQuery();
}
catch {}
finally {
conn.Close();
}
[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: .NET Compact Framework
.NET Framework Security:
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries From Partially Trusted Code
See Also
SqlCeEngine Class | SqlCeEngine Members | System.Data.SqlServerCe Namespace | SqlCeEngine Constructor Overload List
Syntax based on .NET Framework version 1.1.
Documentation version 1.1.1.