Прочетете на английски Редактиране

Споделяне чрез


OdbcParameter Constructors

Definition

Initializes a new instance of the OdbcParameter class.

Overloads

OdbcParameter()

Initializes a new instance of the OdbcParameter class.

OdbcParameter(String, OdbcType)

Initializes a new instance of the OdbcParameter class that uses the parameter name and data type.

OdbcParameter(String, Object)

Initializes a new instance of the OdbcParameter class that uses the parameter name and an OdbcParameter object.

OdbcParameter(String, OdbcType, Int32)

Initializes a new instance of the OdbcParameter class that uses the parameter name, data type, and length.

OdbcParameter(String, OdbcType, Int32, String)

Initializes a new instance of the OdbcParameter class that uses the parameter name, data type, length, and source column name.

OdbcParameter(String, OdbcType, Int32, ParameterDirection, Boolean, Byte, Byte, String, DataRowVersion, Object)

Initializes a new instance of the OdbcParameter class that uses the parameter name, data type, length, source column name, parameter direction, numeric precision, and other properties.

OdbcParameter(String, OdbcType, Int32, ParameterDirection, Byte, Byte, String, DataRowVersion, Boolean, Object)

Initializes a new instance of the OdbcParameter class that uses the parameter name, data type, length, source column name, parameter direction, numeric precision, and other properties.

OdbcParameter()

Source:
OdbcParameter.cs
Source:
OdbcParameter.cs
Source:
OdbcParameter.cs

Initializes a new instance of the OdbcParameter class.

C#
public OdbcParameter();

Examples

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

C#
public void CreateOdbcParameter()
{
   OdbcParameter parameter = new OdbcParameter();
   parameter.ParameterName = "Description";
   parameter.OdbcType = OdbcType.VarChar;
   parameter.Direction = ParameterDirection.Output;
   parameter.Size = 88;
}

Remarks

The base constructor initializes all fields to their default values.

See also

Applies to

.NET 10 (package-provided) и други версии
Продукт Версии
.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)

OdbcParameter(String, OdbcType)

Source:
OdbcParameter.cs
Source:
OdbcParameter.cs
Source:
OdbcParameter.cs

Initializes a new instance of the OdbcParameter class that uses the parameter name and data type.

C#
public OdbcParameter(string? name, System.Data.Odbc.OdbcType type);
C#
public OdbcParameter(string name, System.Data.Odbc.OdbcType type);

Parameters

name
String

The name of the parameter.

type
OdbcType

One of the OdbcType values.

Exceptions

The value supplied in the type parameter is an invalid back-end data type.

Examples

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

C#

public void CreateOdbcParameter()
{
   OdbcParameter parameter = new OdbcParameter("Description",OdbcType.VarChar);
   parameter.Direction = ParameterDirection.Output;
   parameter.Size = 88;
}

See also

Applies to

.NET 10 (package-provided) и други версии
Продукт Версии
.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)

OdbcParameter(String, Object)

Source:
OdbcParameter.cs
Source:
OdbcParameter.cs
Source:
OdbcParameter.cs

Initializes a new instance of the OdbcParameter class that uses the parameter name and an OdbcParameter object.

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

Parameters

name
String

The name of the parameter.

value
Object

An OdbcParameter object.

Remarks

Use caution when you are using this overload of the OdbcParameter 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 OdbcParameter("@pname", Convert.ToInt32(0));

If you do not perform this conversion, the compiler assumes that you are trying to call the OdbcParameter.OdbcParameter constructor overload.

See also

Applies to

.NET 10 (package-provided) и други версии
Продукт Версии
.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)

OdbcParameter(String, OdbcType, Int32)

Source:
OdbcParameter.cs
Source:
OdbcParameter.cs
Source:
OdbcParameter.cs

Initializes a new instance of the OdbcParameter class that uses the parameter name, data type, and length.

C#
public OdbcParameter(string? name, System.Data.Odbc.OdbcType type, int size);
C#
public OdbcParameter(string name, System.Data.Odbc.OdbcType type, int size);

Parameters

name
String

The name of the parameter.

type
OdbcType

One of the OdbcType values.

size
Int32

The length of the parameter.

Exceptions

The value supplied in the type parameter is an invalid back-end data type.

Examples

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

C#

public void CreateOdbcParameter()
{
   OdbcParameter parameter = new OdbcParameter("Description",OdbcType.VarChar,88);
   parameter.Direction = ParameterDirection.Output;
}

See also

Applies to

.NET 10 (package-provided) и други версии
Продукт Версии
.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)

OdbcParameter(String, OdbcType, Int32, String)

Source:
OdbcParameter.cs
Source:
OdbcParameter.cs
Source:
OdbcParameter.cs

Initializes a new instance of the OdbcParameter class that uses the parameter name, data type, length, and source column name.

C#
public OdbcParameter(string? name, System.Data.Odbc.OdbcType type, int size, string? sourcecolumn);
C#
public OdbcParameter(string name, System.Data.Odbc.OdbcType type, int size, string sourcecolumn);

Parameters

name
String

The name of the parameter.

type
OdbcType

One of the OdbcType values.

size
Int32

The length of the parameter.

sourcecolumn
String

The name of the source column.

Exceptions

The value supplied in the type parameter is an invalid back-end data type.

Examples

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

C#
public void CreateOdbcParameter()
{
    OdbcParameter parameter = new OdbcParameter("Description",OdbcType.VarChar,
        88,"Description");
    parameter.Direction = ParameterDirection.Output;
}

See also

Applies to

.NET 10 (package-provided) и други версии
Продукт Версии
.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)

OdbcParameter(String, OdbcType, Int32, ParameterDirection, Boolean, Byte, Byte, String, DataRowVersion, Object)

Source:
OdbcParameter.cs
Source:
OdbcParameter.cs
Source:
OdbcParameter.cs

Initializes a new instance of the OdbcParameter class that uses the parameter name, data type, length, source column name, parameter direction, numeric precision, and other properties.

C#
public OdbcParameter(string? parameterName, System.Data.Odbc.OdbcType odbcType, int size, System.Data.ParameterDirection parameterDirection, bool isNullable, byte precision, byte scale, string? srcColumn, System.Data.DataRowVersion srcVersion, object? value);
C#
public OdbcParameter(string parameterName, System.Data.Odbc.OdbcType odbcType, int size, System.Data.ParameterDirection parameterDirection, bool isNullable, byte precision, byte scale, string srcColumn, System.Data.DataRowVersion srcVersion, object value);

Parameters

parameterName
String

The name of the parameter.

odbcType
OdbcType

One of the OdbcType values.

size
Int32

The length of the parameter.

parameterDirection
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 OdbcParameter.

Exceptions

The value supplied in the odbcType parameter is an invalid back-end data type.

Examples

The following example creates an OdbcParameter and displays the ParameterName.

C#
public void CreateOdbcParameter()
{
    OdbcParameter parameter = new OdbcParameter(
        "Description", OdbcType.VarChar, 11,
        ParameterDirection.Output, true, 0, 0, "Description",
        DataRowVersion.Current, "garden hose");
    Console.WriteLine(parameter.ToString());
}

See also

Applies to

.NET 10 (package-provided) и други версии
Продукт Версии
.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)

OdbcParameter(String, OdbcType, Int32, ParameterDirection, Byte, Byte, String, DataRowVersion, Boolean, Object)

Source:
OdbcParameter.cs
Source:
OdbcParameter.cs
Source:
OdbcParameter.cs

Initializes a new instance of the OdbcParameter class that uses the parameter name, data type, length, source column name, parameter direction, numeric precision, and other properties.

C#
public OdbcParameter(string? parameterName, System.Data.Odbc.OdbcType odbcType, int size, System.Data.ParameterDirection parameterDirection, byte precision, byte scale, string? sourceColumn, System.Data.DataRowVersion sourceVersion, bool sourceColumnNullMapping, object? value);
C#
public OdbcParameter(string parameterName, System.Data.Odbc.OdbcType odbcType, int size, System.Data.ParameterDirection parameterDirection, byte precision, byte scale, string sourceColumn, System.Data.DataRowVersion sourceVersion, bool sourceColumnNullMapping, object value);

Parameters

parameterName
String

The name of the parameter.

odbcType
OdbcType

One of the OdbcType values.

size
Int32

The length of the parameter.

parameterDirection
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 corresponding source column is nullable; false if it is not.

value
Object

An Object that is the value of the OdbcParameter.

Exceptions

The value supplied in the odbcType parameter is an invalid back-end data type.

Examples

The following example creates an OdbcParameter and displays the ParameterName.

C#
public void CreateOdbcParameter()
{
  OdbcParameter parameter = new OdbcParameter("Description",OdbcType.VarChar,
              11,ParameterDirection.Output,true,0,0,"Description",
              DataRowVersion.Current, false, "garden hose");
  MessageBox.Show(parameter.ToString());
}

See also

Applies to

.NET 10 (package-provided) и други версии
Продукт Версии
.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)