OleDbParameter Constructors

Definition

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

Initializes a new instance of the OleDbParameter class.

C#
public OleDbParameter();

Examples

The following example creates an OleDbParameter and sets some of its properties.

C#
public void CreateOleDbParameter()
{
   OleDbParameter parameter = new OleDbParameter();
   parameter.ParameterName = "Description";
   parameter.OleDbType = OleDbType.VarChar;
   parameter.Direction = ParameterDirection.Output;
   parameter.Size = 88;
}

See also

Applies to

.NET 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)

OleDbParameter(String, OleDbType)

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.

C#
public OleDbParameter(string? name, System.Data.OleDb.OleDbType dataType);
C#
public OleDbParameter(string name, System.Data.OleDb.OleDbType dataType);

Parameters

name
String

The name of the parameter to map.

dataType
OleDbType

One of the OleDbType values.

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.

C#

public void CreateOleDbParameter()
{
   OleDbParameter parameter = new OleDbParameter("Description",OleDbType.VarChar);
   parameter.Direction = ParameterDirection.Output;
   parameter.Size = 88;
}

Remarks

The data type, and if appropriate, Size and Precision are inferred from the value of the dataType parameter.

See also

Applies to

.NET 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)

OleDbParameter(String, Object)

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.

C#
public OleDbParameter(string? name, object? value);
C#
public OleDbParameter(string name, object value);

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.

C#

public static void CreateOleDbParameter()
{
   OleDbParameter myParameter = new OleDbParameter("Description", "Beverages");
}

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.

C#
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

.NET 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)

OleDbParameter(String, OleDbType, Int32)

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.

C#
public OleDbParameter(string? name, System.Data.OleDb.OleDbType dataType, int size);
C#
public OleDbParameter(string name, System.Data.OleDb.OleDbType dataType, int size);

Parameters

name
String

The name of the parameter to map.

dataType
OleDbType

One of the OleDbType values.

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.

C#

public void CreateOleDbParameter()
{
   OleDbParameter parameter = new OleDbParameter("Description",OleDbType.VarChar,88);
   parameter.Direction = ParameterDirection.Output;
}

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

.NET 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)

OleDbParameter(String, OleDbType, Int32, String)

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.

C#
public OleDbParameter(string? name, System.Data.OleDb.OleDbType dataType, int size, string? srcColumn);
C#
public OleDbParameter(string name, System.Data.OleDb.OleDbType dataType, int size, string srcColumn);

Parameters

name
String

The name of the parameter to map.

dataType
OleDbType

One of the OleDbType values.

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.

C#

public void CreateOleDbParameter()
{
   OleDbParameter parameter = new OleDbParameter(
       "Description",OleDbType.VarChar,
       88,"Description");
   parameter.Direction = ParameterDirection.Output;
}

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

.NET 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)

OleDbParameter(String, OleDbType, Int32, ParameterDirection, Boolean, Byte, Byte, String, DataRowVersion, Object)

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.

C#
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);
C#
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);

Parameters

parameterName
String

The name of the parameter.

dbType
OleDbType

One of the OleDbType values.

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.

scale
Byte

The total number of decimal places 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 dbType parameter is an invalid back-end data type.

Examples

The following example creates an OleDbParameter and displays the ParameterName.

C#
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());
}

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 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)

OleDbParameter(String, OleDbType, Int32, ParameterDirection, Byte, Byte, String, DataRowVersion, Boolean, Object)

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.

C#
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);
C#
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);

Parameters

parameterName
String

The name of the parameter.

dbType
OleDbType

One of the OleDbType values.

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.

scale
Byte

The total number of decimal places 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 dbType parameter is an invalid back-end data type.

Examples

The following example creates an OleDbParameter and displays the ParameterName.

C#
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());
}

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 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)