OleDbParameter Constructors
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Initializes a new instance of the OleDbParameter class.
Overloads
OleDbParameter() |
Initializes a new instance of the OleDbParameter class. |
OleDbParameter(String, OleDbType) |
Initializes a new instance of the OleDbParameter class that uses the parameter name and data type. |
OleDbParameter(String, Object) |
Initializes a new instance of the OleDbParameter class that uses the parameter name and the value of the new OleDbParameter. |
OleDbParameter(String, OleDbType, Int32) |
Initializes a new instance of the OleDbParameter class that uses the parameter name, data type, and length. |
OleDbParameter(String, OleDbType, Int32, String) |
Initializes a new instance of the OleDbParameter class that uses the parameter name, data type, length, and source column name. |
OleDbParameter(String, OleDbType, Int32, ParameterDirection, Boolean, Byte, Byte, String, DataRowVersion, Object) |
Initializes a new instance of the OleDbParameter class that uses the parameter name, data type, length, source column name, parameter direction, numeric precision, and other properties. |
OleDbParameter(String, OleDbType, Int32, ParameterDirection, Byte, Byte, String, DataRowVersion, Boolean, Object) |
Initializes a new instance of the OleDbParameter class that uses the parameter name, data type, length, source column name, parameter direction, numeric precision, and other properties. |
OleDbParameter()
- Source:
- OleDbParameter.cs
- Source:
- OleDbParameter.cs
- Source:
- OleDbParameter.cs
- Source:
- OleDbParameter.cs
- Source:
- OleDbParameter.cs
Initializes a new instance of the OleDbParameter class.
public:
OleDbParameter();
public OleDbParameter ();
Public Sub New ()
Examples
The following example creates an OleDbParameter and sets some of its properties.
public void CreateOleDbParameter()
{
OleDbParameter parameter = new OleDbParameter();
parameter.ParameterName = "Description";
parameter.OleDbType = OleDbType.VarChar;
parameter.Direction = ParameterDirection.Output;
parameter.Size = 88;
}
Public Sub CreateOleDbParameter()
Dim parameter As New OleDbParameter()
parameter.ParameterName = "Description"
parameter.OleDbType = OleDbType.VarChar
parameter.Direction = ParameterDirection.Output
parameter.Size = 88
End Sub
See also
Applies to
OleDbParameter(String, OleDbType)
- Source:
- OleDbParameter.cs
- Source:
- OleDbParameter.cs
- Source:
- OleDbParameter.cs
- Source:
- OleDbParameter.cs
- Source:
- OleDbParameter.cs
Initializes a new instance of the OleDbParameter class that uses the parameter name and data type.
public:
OleDbParameter(System::String ^ name, System::Data::OleDb::OleDbType dataType);
public OleDbParameter (string? name, System.Data.OleDb.OleDbType dataType);
public OleDbParameter (string name, System.Data.OleDb.OleDbType dataType);
new System.Data.OleDb.OleDbParameter : string * System.Data.OleDb.OleDbType -> System.Data.OleDb.OleDbParameter
Public Sub New (name As String, dataType As OleDbType)
Parameters
- name
- String
The name of the parameter to map.
Exceptions
The value supplied in the dataType
parameter is an invalid back-end data type.
Examples
The following example creates an OleDbParameter and sets some of its properties.
public void CreateOleDbParameter()
{
OleDbParameter parameter = new OleDbParameter("Description",OleDbType.VarChar);
parameter.Direction = ParameterDirection.Output;
parameter.Size = 88;
}
Public Sub CreateOleDbParameter()
Dim parameter As New OleDbParameter("Description", OleDbType.VarChar)
parameter.Direction = ParameterDirection.Output
parameter.Size = 88
End Sub
Remarks
The data type, and if appropriate, Size and Precision are inferred from the value of the dataType
parameter.
See also
Applies to
OleDbParameter(String, Object)
- Source:
- OleDbParameter.cs
- Source:
- OleDbParameter.cs
- Source:
- OleDbParameter.cs
- Source:
- OleDbParameter.cs
- Source:
- OleDbParameter.cs
Initializes a new instance of the OleDbParameter class that uses the parameter name and the value of the new OleDbParameter.
public:
OleDbParameter(System::String ^ name, System::Object ^ value);
public OleDbParameter (string? name, object? value);
public OleDbParameter (string name, object value);
new System.Data.OleDb.OleDbParameter : string * obj -> System.Data.OleDb.OleDbParameter
Public Sub New (name As String, value As Object)
Parameters
- name
- String
The name of the parameter to map.
- value
- Object
The value of the new OleDbParameter object.
Examples
The following example creates an OleDbParameter.
public static void CreateOleDbParameter()
{
OleDbParameter myParameter = new OleDbParameter("Description", "Beverages");
}
Public Shared Sub CreateOleDbParameter()
Dim myParameter As New OleDbParameter("Description", "Beverages")
End Sub
Remarks
Use caution when you are using this overload of the OleDbParameter 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 OleDbParameter("@pname", Convert.ToInt32(0));
If you do not perform this conversion, the compiler assumes that you are trying to call the OleDbParameter constructor overload.
See also
Applies to
OleDbParameter(String, OleDbType, Int32)
- Source:
- OleDbParameter.cs
- Source:
- OleDbParameter.cs
- Source:
- OleDbParameter.cs
- Source:
- OleDbParameter.cs
- Source:
- OleDbParameter.cs
Initializes a new instance of the OleDbParameter class that uses the parameter name, data type, and length.
public:
OleDbParameter(System::String ^ name, System::Data::OleDb::OleDbType dataType, int size);
public OleDbParameter (string? name, System.Data.OleDb.OleDbType dataType, int size);
public OleDbParameter (string name, System.Data.OleDb.OleDbType dataType, int size);
new System.Data.OleDb.OleDbParameter : string * System.Data.OleDb.OleDbType * int -> System.Data.OleDb.OleDbParameter
Public Sub New (name As String, dataType As OleDbType, size As Integer)
Parameters
- name
- String
The name of the parameter to map.
- size
- Int32
The length of the parameter.
Exceptions
The value supplied in the dataType
parameter is an invalid back-end data type.
Examples
The following example creates an OleDbParameter and sets some of its properties.
public void CreateOleDbParameter()
{
OleDbParameter parameter = new OleDbParameter("Description",OleDbType.VarChar,88);
parameter.Direction = ParameterDirection.Output;
}
Public Sub CreateOleDbParameter()
Dim parameter As New OleDbParameter("Description", OleDbType.VarChar, 88)
parameter.Direction = ParameterDirection.Output
End Sub
Remarks
The Size is inferred from the value of the dataType
parameter if it is not explicitly set in the size
parameter.
See also
Applies to
OleDbParameter(String, OleDbType, Int32, String)
- Source:
- OleDbParameter.cs
- Source:
- OleDbParameter.cs
- Source:
- OleDbParameter.cs
- Source:
- OleDbParameter.cs
- Source:
- OleDbParameter.cs
Initializes a new instance of the OleDbParameter class that uses the parameter name, data type, length, and source column name.
public:
OleDbParameter(System::String ^ name, System::Data::OleDb::OleDbType dataType, int size, System::String ^ srcColumn);
public OleDbParameter (string? name, System.Data.OleDb.OleDbType dataType, int size, string? srcColumn);
public OleDbParameter (string name, System.Data.OleDb.OleDbType dataType, int size, string srcColumn);
new System.Data.OleDb.OleDbParameter : string * System.Data.OleDb.OleDbType * int * string -> System.Data.OleDb.OleDbParameter
Public Sub New (name As String, dataType As OleDbType, size As Integer, srcColumn As String)
Parameters
- name
- String
The name of the parameter to map.
- size
- Int32
The length of the parameter.
- srcColumn
- String
The name of the source column.
Exceptions
The value supplied in the dataType
parameter is an invalid back-end data type.
Examples
The following example creates an OleDbParameter and sets some of its properties.
public void CreateOleDbParameter()
{
OleDbParameter parameter = new OleDbParameter(
"Description",OleDbType.VarChar,
88,"Description");
parameter.Direction = ParameterDirection.Output;
}
Public Sub CreateOleDbParameter()
Dim parameter As New OleDbParameter( _
"Description", OleDbType.VarChar, 88, "Description")
parameter.Direction = ParameterDirection.Output
End Sub
Remarks
The Size is inferred from the value of the dataType
parameter if it is not explicitly set in the size
parameter.
See also
Applies to
OleDbParameter(String, OleDbType, Int32, ParameterDirection, Boolean, Byte, Byte, String, DataRowVersion, Object)
- Source:
- OleDbParameter.cs
- Source:
- OleDbParameter.cs
- Source:
- OleDbParameter.cs
- Source:
- OleDbParameter.cs
- Source:
- OleDbParameter.cs
Initializes a new instance of the OleDbParameter class that uses the parameter name, data type, length, source column name, parameter direction, numeric precision, and other properties.
public:
OleDbParameter(System::String ^ parameterName, System::Data::OleDb::OleDbType dbType, int size, System::Data::ParameterDirection direction, bool isNullable, System::Byte precision, System::Byte scale, System::String ^ srcColumn, System::Data::DataRowVersion srcVersion, System::Object ^ value);
public OleDbParameter (string? parameterName, System.Data.OleDb.OleDbType dbType, int size, System.Data.ParameterDirection direction, bool isNullable, byte precision, byte scale, string? srcColumn, System.Data.DataRowVersion srcVersion, object? value);
public OleDbParameter (string parameterName, System.Data.OleDb.OleDbType dbType, int size, System.Data.ParameterDirection direction, bool isNullable, byte precision, byte scale, string srcColumn, System.Data.DataRowVersion srcVersion, object value);
new System.Data.OleDb.OleDbParameter : string * System.Data.OleDb.OleDbType * int * System.Data.ParameterDirection * bool * byte * byte * string * System.Data.DataRowVersion * obj -> System.Data.OleDb.OleDbParameter
Public Sub New (parameterName As String, dbType As OleDbType, size As Integer, direction As ParameterDirection, isNullable As Boolean, precision As Byte, scale As Byte, srcColumn As String, srcVersion As DataRowVersion, value As Object)
Parameters
- parameterName
- String
The name of the parameter.
- size
- Int32
The length of the parameter.
- direction
- ParameterDirection
One of the ParameterDirection values.
- isNullable
- Boolean
true
if the value of the field can be null; otherwise false
.
- precision
- Byte
The total number of digits to the left and right of the decimal point to which Value is resolved.
- srcColumn
- String
The name of the source column.
- srcVersion
- DataRowVersion
One of the DataRowVersion values.
- value
- Object
An Object that is the value of the OleDbParameter.
Exceptions
The value supplied in the dataType
parameter is an invalid back-end data type.
Examples
The following example creates an OleDbParameter and displays the ParameterName.
public void CreateOleDbParameter()
{
OleDbParameter parameter = new OleDbParameter(
"Description", OleDbType.VarChar, 11,
ParameterDirection.Output, true, 0, 0, "Description",
DataRowVersion.Current, "garden hose");
Console.WriteLine(parameter.ToString());
}
Public Sub CreateOleDbParameter()
Dim parameter As New OleDbParameter( _
"Description", OleDbType.VarChar, 11, _
ParameterDirection.Output, True, 0, 0, _
"Description", DataRowVersion.Current, "garden hose")
Console.WriteLine(parameter.ToString())
End Sub
Remarks
The Size and Precision are inferred from the value of the dataType
parameter if they are not explicitly set in the size
and precision
parameters.
See also
Applies to
OleDbParameter(String, OleDbType, Int32, ParameterDirection, Byte, Byte, String, DataRowVersion, Boolean, Object)
- Source:
- OleDbParameter.cs
- Source:
- OleDbParameter.cs
- Source:
- OleDbParameter.cs
- Source:
- OleDbParameter.cs
- Source:
- OleDbParameter.cs
Initializes a new instance of the OleDbParameter class that uses the parameter name, data type, length, source column name, parameter direction, numeric precision, and other properties.
public:
OleDbParameter(System::String ^ parameterName, System::Data::OleDb::OleDbType dbType, int size, System::Data::ParameterDirection direction, System::Byte precision, System::Byte scale, System::String ^ sourceColumn, System::Data::DataRowVersion sourceVersion, bool sourceColumnNullMapping, System::Object ^ value);
public OleDbParameter (string? parameterName, System.Data.OleDb.OleDbType dbType, int size, System.Data.ParameterDirection direction, byte precision, byte scale, string? sourceColumn, System.Data.DataRowVersion sourceVersion, bool sourceColumnNullMapping, object? value);
public OleDbParameter (string parameterName, System.Data.OleDb.OleDbType dbType, int size, System.Data.ParameterDirection direction, byte precision, byte scale, string sourceColumn, System.Data.DataRowVersion sourceVersion, bool sourceColumnNullMapping, object value);
new System.Data.OleDb.OleDbParameter : string * System.Data.OleDb.OleDbType * int * System.Data.ParameterDirection * byte * byte * string * System.Data.DataRowVersion * bool * obj -> System.Data.OleDb.OleDbParameter
Public Sub New (parameterName As String, dbType As OleDbType, size As Integer, direction As ParameterDirection, precision As Byte, scale As Byte, sourceColumn As String, sourceVersion As DataRowVersion, sourceColumnNullMapping As Boolean, value As Object)
Parameters
- parameterName
- String
The name of the parameter.
- size
- Int32
The length of the parameter.
- direction
- ParameterDirection
One of the ParameterDirection values.
- precision
- Byte
The total number of digits to the left and right of the decimal point to which Value is resolved.
- sourceColumn
- String
The name of the source column.
- sourceVersion
- DataRowVersion
One of the DataRowVersion values.
- sourceColumnNullMapping
- Boolean
true
if the source column is nullable; false
if it is not.
- value
- Object
An Object that is the value of the OleDbParameter.
Exceptions
The value supplied in the dataType
parameter is an invalid back-end data type.
Examples
The following example creates an OleDbParameter and displays the ParameterName.
public void CreateOleDbParameter()
{
OleDbParameter parameter = new OleDbParameter(
"Description", OleDbType.VarChar, 11,
ParameterDirection.Output, true, 0, 0, "Description",
DataRowVersion.Current, "garden hose");
Console.WriteLine(parameter.ToString());
}
Public Sub CreateOleDbParameter()
Dim parameter As New OleDbParameter( _
"Description", OleDbType.VarChar, 11, _
ParameterDirection.Output, True, 0, 0, _
"Description", DataRowVersion.Current, "garden hose")
Console.WriteLine(parameter.ToString())
End Sub
Remarks
The Size and Precision are inferred from the value of the dataType
parameter if they are not explicitly set in the size
and precision
parameters.
See also
Applies to
.NET