Share via


SqlCeCommand Constructor (String, SqlCeConnection)

Initializes a new instance of the SqlCeCommand class with the text of the query and a SqlCeConnection.

Namespace:  System.Data.SqlServerCe
Assembly:  System.Data.SqlServerCe (in System.Data.SqlServerCe.dll)

Syntax

'Declaration
Public Sub New ( _
    commandText As String, _
    connection As SqlCeConnection _
)
'Usage
Dim commandText As String
Dim connection As SqlCeConnection

Dim instance As New SqlCeCommand(commandText, _
    connection)
public SqlCeCommand(
    string commandText,
    SqlCeConnection connection
)
public:
SqlCeCommand(
    String^ commandText, 
    SqlCeConnection^ connection
)
new : 
        commandText:string * 
        connection:SqlCeConnection -> SqlCeCommand
public function SqlCeCommand(
    commandText : String, 
    connection : SqlCeConnection
)

Parameters

Remarks

The following table shows initial property values for an instance of SqlCeCommand.

Properties

Initial Value

CommandText

cmdText

CommandType

Text

Connection

A new SqlCeConnection that is the value for the connection parameter.

You can change the value for any of these parameters by setting the related property.

Examples

The following example creates a SqlCeCommand and sets some of its properties.

conn.Open()
Dim cmd As New SqlCeCommand("INSERT INTO foo (col1) VALUES (1)", conn)
cmd.ExecuteNonQuery()
conn.Close()
conn.Open();
SqlCeCommand cmd = new SqlCeCommand("INSERT INTO foo (col1) VALUES (1)", conn);
cmd.ExecuteNonQuery();
conn.Close();

See Also

Reference

SqlCeCommand Class

SqlCeCommand Members

SqlCeCommand Overload

System.Data.SqlServerCe Namespace