SqlCeParameter.SqlCeParameter(String, Object) Constructor
Initializes a new instance of the SqlCeParameter class with the parameter name and the value of the new SqlCeParameter.
Namespace: System.Data.SqlServerCe
Assembly: System.Data.SqlServerCe (in system.data.sqlserverce.dll)
Syntax
'Declaration
Public Sub New ( _
name As String, _
value As Object _
)
'Usage
Dim name As String
Dim value As Object
Dim instance As New SqlCeParameter(name, value)
public SqlCeParameter (
string name,
Object value
)
public:
SqlCeParameter (
String^ name,
Object^ value
)
public SqlCeParameter (
String name,
Object value
)
public function SqlCeParameter (
name : String,
value : Object
)
Not applicable.
Parameters
- name
The name of the parameter to map.
- value
The value of the new SqlCeParameter object.
Exceptions
Exception type | Condition |
---|---|
The value supplied for the parameter cannot be converted to a database type supported by SQL Server Compact Edition. |
Remarks
When you specify an Object in the value parameter, the SqlDbType is inferred from the .NET Framework type of the Object.
Use caution when using this overload of the SqlCeParameter constructor to specify integer parameter values. Because this overload takes a value of type Object, you must convert the integral value to an Object type when the value is zero, as the following C# example demonstrates.
Parameter = new SqlParameter("@pname", Convert.ToInt32(0));
If you do not perform this conversion, the compiler will assume you are attempting to call the SqlParameter (string, SqlDbType) constructor overload.
Example
The following example creates a SqlCeParameter.
' Create and assign a value to a parameter of SqlDbType.NChar (String).
Dim p2 As New SqlCeParameter("@Description", "Soft drinks, coffees, teas, beers, and ales")
' Create and assign a value to a parameter of SqlDbType.Int (Int32).
Dim p1 As New SqlCeParameter("@CategoryID", 1)
p1.SqlDbType = SqlDbType.Int
// Create and assign a value to a parameter of SqlDbType.NChar (String).
SqlCeParameter p2 = new SqlCeParameter("@Description", "Soft drinks, coffees, teas, beers, and ales");
// Create and assign a value to a parameter of SqlDbType.Int (Int32).
SqlCeParameter p1 = new SqlCeParameter("@CategoryID", 1);
p1.SqlDbType = SqlDbType.Int;
Platforms
Windows CE, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows XP Professional x64 Edition, Windows XP SP2
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.
Version Information
.NET Framework
Supported in: 3.0
.NET Compact Framework
Supported in: 2.0, 1.0
See Also
Reference
SqlCeParameter Class
SqlCeParameter Members
System.Data.SqlServerCe Namespace