Export (0) Print
Expand All

SqlCeCommand.CreateParameter Method

Creates a new instance of a SqlCeParameter object.

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

public SqlCeParameter CreateParameter()

The CreateParameter method is a strongly-typed version of CreateParameter.

The following example creates a SqlCeCommand and uses the CreateParameter property to create parameters.

SqlCeConnection conn = null;
SqlCeDataReader rdr = null;

try
{
    conn = new SqlCeConnection(connStr);
    conn.Open();

    SqlCeCommand cmd = new SqlCeCommand("SELECT * FROM myTable", conn);
    cmd.Connection.Open();

    rdr = cmd.ExecuteReader();

    while (rdr.Read())
    {
        Console.WriteLine(rdr.GetString(0));
    }
}
finally
{
    rdr.Close();
    conn.Close();
}


Show:
© 2015 Microsoft