SqlCeCommand.CreateParameter Method
Creates a new instance of a SqlCeParameter object.
Namespace: System.Data.SqlServerCe
Assembly: System.Data.SqlServerCe (in System.Data.SqlServerCe.dll)
Syntax
'Declaration
Public Function CreateParameter As SqlCeParameter
'Usage
Dim instance As SqlCeCommand
Dim returnValue As SqlCeParameter
returnValue = instance.CreateParameter()
public SqlCeParameter CreateParameter()
public:
SqlCeParameter^ CreateParameter()
member CreateParameter : unit -> SqlCeParameter
public function CreateParameter() : SqlCeParameter
Return Value
Type: System.Data.SqlServerCe.SqlCeParameter
A SqlCeParameter object.
Remarks
The CreateParameter method is a strongly-typed version of CreateParameter.
Examples
The following example creates a SqlCeCommand and uses the CreateParameter property to create parameters.
Dim conn As SqlCeConnection = Nothing
Dim rdr As SqlCeDataReader = Nothing
Try
conn = New SqlCeConnection(connStr)
conn.Open()
Dim cmd As New SqlCeCommand("SELECT * FROM myTable", conn)
cmd.Connection.Open()
rdr = cmd.ExecuteReader()
While rdr.Read()
Console.WriteLine(rdr.GetString(0))
End While
Finally
rdr.Close()
conn.Close()
End Try
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();
}